trailing white space

May 17, 2009 at 06:52:31
Specs: Windows Vista
Hi,

With this loop I can replace a text string in a text file.
But the output has some trailing white space and I can't find the cause of it.

SetLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%G in ('type "%cd%\test.txt"') do (
set lines=%%G
set lines=!lines:changethis=%cd%!
echo !lines!>> "%cd%\test2.txt" )

test.txt

changethis


Who can help me?

Thx in advance


See More: trailing white space

Report •


#1
May 17, 2009 at 09:43:48
I found the solution:

SetLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%G in ('type "%cd%\test.txt"') do (
set lines=%%G
set lines=!lines:changethis=%cd%!
echo !lines!>> "%cd%\test2.txt"
)

The bracket had to be on a new line.

Report •
Related Solutions


Ask Question