in reply to Remove ^M using script

Some information about this is at: Newline

Also if you are using a *nix/BSD OS you might try this at the command line:

tr -d '\r' < inputfile > outputfile

I know this really isn't a "script", but just another way to do it. You could just make a system call to tr, and write some extra code to handle switches/parameters.