Computing.Net > Forums > Programming > Bat File edit text file

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.

Bat File edit text file

Reply to Message Icon

Name: Mickman
Date: May 15, 2002 at 11:15:08 Pacific
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: MacFromOK
Date: May 15, 2002 at 16:28:48 Pacific
Reply:

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


0

Response Number 2
Name: DAVID
Date: May 16, 2002 at 18:12:55 Pacific
Reply:

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 Loop

SET 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.zip

http://home7.inet.tele.dk/batfiles/
http://www.fpschultze.de/batstuff.html
GOOD LUCK


0

Response Number 3
Name: MacFromOK
Date: May 17, 2002 at 23:18:22 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
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: Bat File edit text file

editing text files www.computing.net/answers/programming/editing-text-files/19274.html

editing text file with batch file www.computing.net/answers/programming/editing-text-file-with-batch-file/15231.html

make batch file edit text file www.computing.net/answers/programming/make-batch-file-edit-text-file/15584.html