How to delete carriage return and online feed characters from a text file using a batch?

advertisements

I've a fixed width text file so it contains leading zeros and spaces and I need to remove carriage return and line feed characters from the file. Could you please let me know how can I do this using batch script?

Input:

ABCDEF  GHIJK0000ADS
ABCDEF  GHIJK0000ADS
ABCDEF  GHIJK0000ADS

Output:

ABCDEF  GHIJK0000ADSABCDEF  GHIJK0000ADSABCDEF  GHIJK0000ADS

Thanks, Niranjan


setlocal enabledelayedexpansion
set "line="
for /f "delims=" %%a in (filename.txt) do set "line=!line!%%a"
echo %line%

Read each line;accumulate. Relies on delayed expansion mode