文件字符串替换
文件字符串替换
@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
ps:本博文只用于日常备注及学习交流,请勿用于任何商业用途,涉及网摘等资料如有侵犯原作者权利,请联系确保及时更正!