I am new to batch and this site. I searched for similar question and found some. But they are pointed towards having FART or other third party installations. But I need only batch script. Please help me in this.
I have multiple .txt files in a folder C:\files. All the files have text '>>superman<<' in them. I want to replace it with '>>batman<<' without creating any new files.
@echo off
SETLOCAL
for %%* in (.) do set foldername=%%~n*
SET stringtofindreplace=XXXX
for %%f in (*.fmw) do (
echo Processing %%f...
fOR /F "delims=" %%l IN (%%f) DO (
SET "line=%%l"
SETLOCAL ENABLEDELAYEDEXPANSION
set "x=!line:%stringtofindreplace%=%foldername%!"
echo(!x!
ENDLOCAL)
)>%%~nf.new
)
GOTO:EOF
Thanks in advance