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.
DOS Batch: Remove Trailing Space
Name: jimrockford Date: January 23, 2004 at 08:39:23 Pacific OS: Windows XP CPU/Ram: P4 2.6Ghz/512Mb
Comment:
Is there an easy way to remove trailing space characters from the contents of a variable? I want to do it using straight DOS commands. The number of trailing spaces will vary but the variable will always end with "WGM".
Name: IVO Date: January 25, 2004 at 09:18:54 Pacific
Reply:
If you are still interested, the following sample batch does what you want: --- @Echo Off
Set MyVar=AA AAAA Echo MyVar=[%MyVar%]
Call :TRIM %MyVar%
Echo MyVar=[%MyVar%] Set MyVar= GoTo :EOF
:TRIM Set MyVar=%* GoTo :EOF ----- where the initial setting of MyVar ends with trailing balnks that are removed by the internal subroutine :TRIM (that is all you need to get your goal).
The :EOF label must not be declared explicitly as it is the standard return point in NT-kernel based scripts.
Summary: Hello, I often have some ascii text files that need edited. Not wanting to do the same task over and over, I want to make a batch file. Here is and idea given to me by another poster. So I have 100 or...
Summary: Thank you both so much for your help. I'm now thinking that instead of "Removing" the lines, I need to do a "Search/Replace". This is what I'm now thinking. Basically I found a post (http://www.comput...
Summary: Hello, I have about 100 text files. They are full of extra stuff that needs to be cleaned up. The stuff is one or more blank lines, trailing spaces, comment lines that start with a "#" and one byte th...