Batch to change a line in a text file

Hewlett-packard / Hp compaq dc7800 converti...
June 10, 2010 at 03:14:05
Specs: Microsoft Windows XP Professional, 1.795 GHz / 1004 MB
Hello. I am looking for help to create two batch files. Or maybe one would be enough.
I want to have batch file on my desktop, so I can run it whenever I want to change those lines in file S:\xxx\aaa\sss\realmlist.ext. I find two ways to do that. One create two batches. One changes line to something like "Set Realmlist" and the other to "Set Realmlist". And the other way - one batch. First it scans existing realmlist.ext, then processes depending on the line already existing. So if "Set Realmlist", changes to the other one. And it would be very nice, if after scanning and changing, script would print the output, which line was changed to which one. Thanks!

See More: Batch to change a line in a text file

Report •

June 10, 2010 at 07:20:25
@echo off & setlocal
ren realmlist.ext realmlist.tmp
ren realmlist.bak realmlst.ext
ren realmlist.tmp realmlist.bak
echo "current setting:"
findstr /b "Set Realmlist" realmlist.ext
::------ end
I use a similar approach to enable/disable my hosts file.
you could also change the file itself, but you still have to
pump it out to a tmp file then rewrite back over the .ext.

Report •
Related Solutions

Ask Question