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 ! with " " and always save it to a file called OUTPUT.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.
Code: Select all
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
::syntax: FindReplace.bat OldStr NewStr OldFilename >>NewFileName
:: OldStr [in] - string to be replaced
:: NewStr [in] - string to replace with
:: OldFilename [in] - file to be parsed
:: NewFilename [output] - new output filename
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
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.
)