@echo off
:: Preserve blank lines and replace strings (Note: If replacing a batch program, the identifier ":" will be lost, and "=" cannot be replaced)
echo.
set /p waei= Drag the file whose characters you want to replace to this window:
echo.
set /p wasy= Enter the text to be replaced:
echo.
set /p sybm= Enter the replacement text:
echo.
echo The program is running, please wait... ...
set "waei=%waei:"=%"
for %%i in ("%waei%") do set waei=%%~fi
cd.>"%waei%_tmp.txt"
setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%waei%"') do (
set str=%%j
if not "!str!"=="" set "str=!str:%wasy%=%sybm%!"
>>"%waei%_tmp.txt" echo.!str!
)
copy "%waei%" "%waei%_bak.txt" >nul 2>nul
move "%waei%_tmp.txt" "%waei%"
@cls
@echo.
@echo Replacement completed
pause>nul