- @echo off
- set /p s1=Enter value for s1:
- set /p s2=Enter value for s2:
-
- rem Escape exclamation marks in s1 and s2
- set "s1=%s1:!=^^^!!%"
- set "s2=%s2:!=^^^!!%"
-
- cd.>3.out.txt
- for /f "delims=" %%j in ('findstr .* 3.txt') do (
- set "val=%%j"
- call :replace val s1 s2
- setlocal enabledelayedexpansion
- echo.!val!
- endlocal
- ) >> 3.out.txt
-
- pause
- goto :eof
-
- :replace <var> <search> <replace>
- setlocal enabledelayedexpansion
- for /f "tokens=1,* delims==" %%a in ('set %~1') do (
- set "temp=%%b"
- set "%~1=!temp:%~2=%~3!"
- )
- endlocal & set "%~1=%temp%"
- goto :eof
复制代码 回复 1# tiandyoin
chatgpt 又给我卷出这串代码,感觉要抓狂,但结果错的离谱 |