加强版
@璐村惂鐢ㄦ埛_000076K馃惥 off&title 替换字符&color F0
mode con cols=80 lines=20
setlocal EnableDelayedExpansion
set /p fileP=请输入要替换字符的文件路径:
if not exist "%~dp0\bakup" md "%~dp0\bakup"
copy %fileP% %~dp0\bakup >nul
copy %fileP% %~dp0\tmp.txt
type %fileP%>%fileP%
start "" "%~dp0\tmp.txt"
set /p str1=请把需要替换字符的那一行复制过来:
set /p str2=要替换这一行的那串字符的(紧挨着的,不能隔字符):
set /p str3=要把%str2%替换成什么:
for /f "delims=" %%a in (%~dp0\tmp.txt) do (
if "%%a" equ "%str1%" (
set line=%%a
set "line=!line:%str2%=%str3%!"
>>%fileP% echo !line!
) else (
set no=%%a
>>%fileP% echo !no!
)
)
start "" "%fileP%"
del /q %~dp0\tmp.txt&pause
