文件字符串替换
@echo off echo ***** Replace "abcd" as "ABCD" ***** set strFilePath=C:UsersLeezDesktopTestBatTestSource.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