Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
I am trying to edit a text file from a .bat file and can't seem to find a command that can crop the ends of the text string. The other solution would be to write the data to the screen and then manipulate it, but again i have not been able to accomplish this. Any help would be greatly apprereciated.

You cannot edit a text file from a DOS
batch file, unless you have some utility
that would enable you to do this (BTW,
I don't know of one).Exactly what are you trying to do, and
why from a batch file?Cheers, Mac

Strip the first character, which happens to be a known delimiter, using ECHO:
ECHO;ABC
ECHO:ABC
ECHO,ABC
ECHO.ABC
ECHO=ABC
ECHO+ABC
ECHO[ABC
ECHO]ABC
ECHO/ABC
ECHO\ABC
will all display ABC
Strip any character anywhere in the string using CHOICE (MS-DOS 6 and later, Windows NT/2000 with the Resource Kit):
IF "%1"=="Loop" GOTO LoopSET KEY=[HKEY_LOCAL_MACHINE\Enum\SCSI]
ECHO ]¦ CHOICE /C:;%KEY%;] %0 Loop > TEMP.BAT
CALL TEMP.BAT
ECHO Registry key is: %KEY%
GOTO End:Loop
REM Strips square brackets from KEY variable
SHIFT
IF "%1"=="]" GOTO End
IF NOT "%1"=="[" SET KEY=%KEY%%1
GOTO Loop:End
This may not work if your CHOICE version's output cannot be redirected, as in some Dutch Windows 98 versions.
Strip both leading and trailing double quotes in Windows 95 /98, using FOR:
FOR %%A IN ("A B C") DO SET STRING=%%A
ECHO.%STRING%
will display
A B C
Or use NT's SET's parameter substitution to replace characters in a string:
SET STRING=[ABCDEFG]
SET NEWSTRING=%STRING:[=%
SET STRING=%NEWSTRING:]=%
ECHO String: %STRING%
will display
String: ABCDEFG
or
SET STRING=[ABCDEFG]
SET NEWSTRING=%STRING:[=(%
SET STRING=%NEWSTRING:]=)%
ECHO String: %STRING%
will display
String: (ABCDEFG)
or
SET STRING=[ABCDEFG]
SET NEWSTRING=%STRING:~1,7%
ECHO String: %NEWSTRING%
will display
String: ABCDEFG
FROM
http://www.robvanderwoude.com/ftp://ftp.filegate.net/pub/bfds/batpwr04.zip
ftp://ftp.filegate.net/pub/bfds/bat-tnt.zip
ftp://ftp.filegate.net/pub/bfds/batpwr03.zip
ftp://ftp.filegate.net/pub/bfds/batpwr01.zip
ftp://ftp.filegate.net/pub/bfds/batpwr1b.zip
ftp://ftp.filegate.net/pub/bfds/batpwr1a.zip
ftp://ftp.filegate.net/pub/bfds/batpwr1c.zip
ftp://ftp.filegate.net/pub/bfds/batpwr02.ziphttp://home7.inet.tele.dk/batfiles/
http://www.fpschultze.de/batstuff.html
GOOD LUCK

Well, I assumed he wanted to edit the file
using a batch file as a command. If you're
gonna use CHOICE (requiring user input),
why not use a text editor (edit, etc.) in
the first place? Or am I missing something
here...Cheers, Mac

![]() |
![]() |
![]() |

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