Replace string in a file using windows script

April 26, 2019 at 03:31:11
Specs: DOS
this script is working for the string. I want a script to accept a file as input and replace string across the file.

set str=teh cat in teh hat
echo.%str%
set str=%str:teh=the%
echo.%str% > C:\replace.txt

teh cat in teh hat
the cat in the hat

Thanks for the help


See More: Replace string in a file using windows script

Report •

#1
June 12, 2019 at 03:55:06
What about this:

for /F "tokens=*" %%A in (' type C:\replace.txt ') do set tempvar=%%A
set str=%tempvar:teh=the%


Report •
Related Solutions


Ask Question