@echo off
echo ***** Replace "abcd" as "ABCD" *****
set strFilePath=C:\Users\Leez\Desktop\TestBat\TestSource.txt
set strOld=abcd
set strNew=ABCD
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (%strFilePath%) do (
set "var=%%i"
if not !var!.==. (
set "var=!var:%strOld%=%strNew%!"
echo !var!!>>%strFilePath%.bk
)
)
move /y %strFilePath%.bk %strFilePath%
pause
时间: 2024-10-25 20:45:02