Preserve blank lines in a dos for loop
Posted: 13 Sep 2011 09:02
Hi,
I use a dos script to alter the txt output of my LDIFDE script. The output contains many lines and blank lines. I change a line from 'changetype: add' to 'objectclass: top objectclass: person'.
It's very good at making the line change but also removes blank lines. I need the blank lines preserving. Please help?
setlocal enabledelayedexpansion
if not exist "%1" (echo file not found..)&goto :eof
for /f "tokens=* delims=" %%a in (%1) do (
if "%%a"=="changetype: add" set write=objectclass: top objectclass: person
echo !write!
(echo !write!)>>%~n1.replaced%~x1
)
I have tried "delims= "
Thanks
Staro
I use a dos script to alter the txt output of my LDIFDE script. The output contains many lines and blank lines. I change a line from 'changetype: add' to 'objectclass: top objectclass: person'.
It's very good at making the line change but also removes blank lines. I need the blank lines preserving. Please help?
setlocal enabledelayedexpansion
if not exist "%1" (echo file not found..)&goto :eof
for /f "tokens=* delims=" %%a in (%1) do (
if "%%a"=="changetype: add" set write=objectclass: top objectclass: person
echo !write!
(echo !write!)>>%~n1.replaced%~x1
)
I have tried "delims= "
Thanks
Staro