:substitute

substitutes a string in a text file

Description: call:substitute OldStr NewStr File
Script:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
:substitute OldStr NewStr File -- substitutes a string in a text file
::                             -- OldStr [in] - string to be replaced
::                             -- NewStr [in] - string to replace with
::                             -- File   [in] - file to be parsed
:$created 20060101 :$changed 20101122 :$categories FileManipulation
:$source https://www.dostips.com
SETLOCAL DISABLEDELAYEDEXPANSION
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
    set "line=%%B"
    if defined line (
        call set "line=echo.%%line:%~1=%~2%%"
        for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
    ) ELSE echo.
)
EXIT /b