What do you mean by "shell script" then?
What environment are you working in?
Can you run bash? If so, you could run the following one-liner in the directory with the cpp files. First make a new directory in it called "fixed" where the fixed files will go.
for f in *.cpp; do cat "$f" | tr -d '\r' > "fixed/$f"; done
yes you are correct, but we are using the code files in other application after transferring them as binary. We are getting control M character error on that application. so trying to create a script file to remove all the hidden ^M character.
In that case you can run the following script on Windows. Copy the code into a file, stripcr.vbs. Run it in the current folder by specifying the file extensions that you want to process like stripcr cpp h txt. Note that if you haven't previously done
cscript //h:cscript //save
to set cscript as the default you will have to run the script as
cscript stripcr.vbs cpp h txt
or you will get a MsgBox popup for every file processed (really annoying).
set fso = CreateObject("Scripting.FileSystemObject")
for each ext in wscript.arguments
ext = lcase(ext)
for each file in fso.GetFolder(".").Files
if lcase(fso.GetExtensionName(file)) = ext then
text = fso.OpenTextFile(file.Name).ReadAll
text = Replace(text,vbCr,"")