I need a batch file which searches a text file for a string and replaces it with another string. I tried to do something like this but it doesn't work. Can anyone tell me what I'm doing wrong?
@echo off
setLocal DisableDelayedExpansion
if not exist "%1" (echo FindAndReplace: File Not Found)
set /p findX= Find ?
set /p replaceWithX= Replace With ?
for /f "tokens=* delims= " %%G in (%1) do (
set str=%%G
setLocal EnableDelayedExpansion
set str=!str:[%findX%]=[%replaceWithX%]!
>> %1.txt echo(!str!
endlocal
)