如果替换的是一整行就比较简单,如果不是一整行,而是一行中的一部分就很有些麻烦
写个简单的且只考虑需要替换的只一行:
@echo off
set f=xx.ini
set s1=LOCAL_CODEPAGE=windows-936-2000
set s2=LOCAL_CODEPAGE=cp1252
for /f "delims=:" %%a in (findstr/in "%s1%" "%f%")do set n=%%a
(for /f "tokens=1* delims=:" %%a in ('findstr/n ".*" "%f%"')do (
if %%a equ %n% (echo.%s2%)else echo.%%b
))>newfile
move newfile "%f%"
echo 替换完毕&ping -n 2 127.1>nul
撒爱上