windows 批处理bat字符串替换;
bat 示例:
@echo off echo ***** 替换IP ***** set strFilePath=C:\Users\Administrator\Desktop\123\123.txt set str_ip=127.0.0.1 set chk_ip=172.16.2.17 setlocal enabledelayedexpansion for /f "tokens=*" %%i in (%strFilePath%) do ( set "var=%%i" if not !var!.==. ( set "var=!var:%str_ip%=%chk_ip%!" echo !var!!>>%strFilePath%.bak ) ) move /y %strFilePath%.bak %strFilePath% pause
文件copy 备份
:: 复制备份 copy "C:\Users\Administrator\Desktop\123\123.txt" "C:\Users\Administrator\Desktop\123\123.txt-bak"
来源:https://www.cnblogs.com/sharesdk/p/12410882.html