Computing.Net > Forums > Programming > trailing white space

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

trailing white space

Reply to Message Icon

Name: MaRtO
Date: May 17, 2009 at 06:52:31 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: MaRtO
Date: May 17, 2009 at 09:43:48 Pacific
Reply:

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.

0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: trailing white space

del blank lines, remove white space www.computing.net/answers/programming/del-blank-lines-remove-white-space/15304.html

White space? www.computing.net/answers/programming/white-space/14757.html

scanning white spaces in C www.computing.net/answers/programming/scanning-white-spaces-in-c/9549.html