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.
Find and Replace
Name: ryanpete Date: February 27, 2007 at 08:40:38 Pacific OS: Xp Sp2 CPU/Ram: 2.99/512 Product: Dell/Optiplex GX520
Comment:
I need help making a batch file that will find the string "SERVICEACCOUNT" in the file settings.xml and replace it with the varible %username%.
Name: cup Date: February 27, 2007 at 14:30:48 Pacific
Reply:
Are you allowed to use external exes or does it have to be vanilla XP.
0
Response Number 2
Name: ryanpete Date: February 28, 2007 at 06:21:27 Pacific
Reply:
I would preffer to use vanilla XP, but at the moment I have it working with change.exe
0
Response Number 3
Name: dtech10 Date: February 28, 2007 at 06:51:37 Pacific
Reply:
Hi ryanpete
@echo off setlocal EnableDelayedExpansion
@echo off > ~txt.txt for /f "tokens=*" %%a in (settings.xml) do ( set C=%%a set B=!C:SERVICEACCOUNT=%username%! echo [!B!] >> ~txt.txt
) del settings.xml ren ~txt.txt settings.xml
0
Response Number 4
Name: Shr0Om Date: February 28, 2007 at 06:56:06 Pacific
Reply:
Try this. If you want the local username to be used, remove "set /p username=Username?:"
::CODE @echo off SetLocal EnableDelayedExpansion set /p username=Username?: For /F "tokens=1-2* delims=" %%A in (inputfile.xml) Do ( Set TxtLine=%%A Echo !TxtLine:SERVICEACCOUNT=%username%!>>tmp) del inputfile.xml ren tmp inputfile.xml endlocal
Summary: I need to figure out a method to find and replace text within a text file. I have a file named, "myfile.txt" that has the following; testing=1 database=500 rules=30 I want the batch file to find datab...
Summary: Hello, I was trying to create a batchfile that will perform find and replace for a user defined string (both for find and replace) within a group of files. I havent had much luck. Any help would be gr...
Summary: Hi. i am trying to use a dos script to find and replace some text, maybe look up some values, for example, i have a dinamically generated text file containing information like this: product 1 product ...