Replace text in bat files
Posted: 10 Mar 2011 03:58
Hi All
I have set of bat files. all bat file contain 'TEST_2011' text. I want to replace TEST_2011 with TEST_2012. My bat files names are r1.bat,r2.bat,r3.bat and r4.bat. Thing is I want to replace new text in all bat files at once. I tried following bat file to replace new text into bat files. But Still I can replace only in r1.bat. I expect replace new text into all bat files which are r1.bat,r2.bat,r3.bat and r4.bat. Please advise me how to fulfill my requirement.
@echo off >newr1.bat & setLocal enableDELAYedexpansion
set /p old=old string ?
set /p new=new string ?
for /f "tokens=* delims= " %%a in (r1.bat) do (
set str=%%a
set str=!str:%old%=%new%!
>> newr1.bat echo !str!
)
Thank you
I have set of bat files. all bat file contain 'TEST_2011' text. I want to replace TEST_2011 with TEST_2012. My bat files names are r1.bat,r2.bat,r3.bat and r4.bat. Thing is I want to replace new text in all bat files at once. I tried following bat file to replace new text into bat files. But Still I can replace only in r1.bat. I expect replace new text into all bat files which are r1.bat,r2.bat,r3.bat and r4.bat. Please advise me how to fulfill my requirement.
@echo off >newr1.bat & setLocal enableDELAYedexpansion
set /p old=old string ?
set /p new=new string ?
for /f "tokens=* delims= " %%a in (r1.bat) do (
set str=%%a
set str=!str:%old%=%new%!
>> newr1.bat echo !str!
)
Thank you