Expanding from Andriy M, and yes you can do this from a file, even one with multiple lines
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set "INTEXTFILE=test.txt"
set "OUTTEXTFILE=test_out.txt"
set "SEARCHTEXT=bath"
set "REPLACETEXT=hello"
for /f "delims=" %%A in ('type "%INTEXTFILE%"') do (
set "string=%%A"
set "modified=!string:%SEARCHTEXT%=%REPLACETEXT%!"
echo !modified!>>"%OUTTEXTFILE%"
)
del "%INTEXTFILE%"
rename "%OUTTEXTFILE%" "%INTEXTFILE%"
endlocal
EDIT
Thanks David Nelson, I have updated the script so it doesn't have the hard coded values anymore.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…