1.

Solve : find replace a string with new line?

Answer»

Hi All,


I have a windows directory with files   file_835_2014_JULDAY_XXX.txt

C:\0001_krishna\file_835_2014_JULDAY_001.txt
C:\0001_krishna\file_835_2014_JULDAY_002.txt
C:\0001_krishna\file_835_2014_JULDAY_003.txt  and so on.

Now in each of this file, I have text as follows without linefeed (New line).
ISA*......~GS*.....~ST*....~BPR.....

I would like to have a BATCH file , which would convert all these files with line feed (new line)  for every TILDA (~)
ISA*......~
GS*.....~
ST*....~
BPR.....

Can you please help me , so that when I run that batch script, all the files in my folder C:\0001_krishna\*.txt  will convert to above new line format.

Thank you
KrishnaTest this on a folder with sample files inside:

Code: [SELECT]echo off
for %%a in (*.txt) do (
type "%%a"|repl "~" "~\r\n" x >"%%a.tmp"
)
del *.txt
ren *.tmp *.
echo done
pause

This uses a helper batch file called `repl.bat` (by dbenham) - download from:  https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

Place `repl.bat` in the same folder as the batch file or in a folder that is on the path.



Discussion

No Comment Found