|Hoping someone can help me modify the attached batch file. Currently, this batch file basically finds and replaces text within a file. Currently, parameters are passed at the command line |
when executed. For example, if I want to find and replace the word
"Home" with "work" and save to a new file called TempA.txt, at the
command line, I type in:
FindReplace.bat "home" "work" >>TempA.txt
I need to modify this batch file so that there is no need to pass
the parameters. I want the parameters hardcoded in the logic below to always
find and replace "home" with "work" and always save it to a file
called TempA.txt This way, all I have to do is just type FindReplace.bat at
the command prompt.
Can someone help me modify the code below to hard code the find and replace
values within the batch file along with the NewFilename?
Any help is greatly appreciated.
::syntax: FindReplace.bat OldStr NewStr >>NewFileName
:: OldStr [in] - string to be replaced
:: NewStr [in] - string to replace with
:: File [in] - file to be parsed
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
if defined line (
call set "line=echo.%%line:%~1=%~2%%"
for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
) ELSE echo.