tag:blogger.com,1999:blog-8993268673873713026.post9117459785735864230..comments2023-04-10T04:33:08.159-07:00Comments on Points of Note: Removing carriage returns from a text file using a DOS batch fileAnonymoushttp://www.blogger.com/profile/15748502908148317084noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8993268673873713026.post-2571529060501520962016-05-24T06:20:09.852-07:002016-05-24T06:20:09.852-07:00Hi,
I have tried the below script to remove the ca...Hi,<br />I have tried the below script to remove the carriage return from the end of line from a text file.after executing the script it displays only the last record in the file removing the carriage return.<br />can anyone help me on this.<br />@echo off<br />SetLocal DisableDelayedExpansion<br />for /f "tokens=*" %%a in ('find /n /v "" ^< "old_file.txt"') do (<br />set line=%%a<br />SetLocal EnableDelayedExpansion<br />set line=!line:*]=!<br />rem "set /p" won't take "=" at the start of a line....<br />if "!line:~0,1!"=="=" set line= !line!<br /><br />rem there must be a blank line after "set /p"<br />rem and " "new_file.txt"Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8993268673873713026.post-748044104395056072013-03-16T19:09:57.896-07:002013-03-16T19:09:57.896-07:00Thank you. This is perfect.
It works.Thank you. This is perfect. <br />It works.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8993268673873713026.post-86869191927729859282012-08-14T07:41:18.877-07:002012-08-14T07:41:18.877-07:00for /f "delims=" %%a in (myfile.txt) do ...for /f "delims=" %%a in (myfile.txt) do (<br />echo/|set /p ="%%a%"<br />)>>newfile.txtAnonymousnoreply@blogger.com