本帖最后由 went 于 2022-3-26 15:35 编辑
test.bat,A.txt,B.txt均保存为ansi编码- @echo off & cd /d "%~dp0"
- setlocal enabledelayedexpansion
- REM txt设置
- set "t1=A.txt"
- set "t2=B.txt"
- for %%i in ("%t1%") do set "new_file=%%~ni_NEW%%~xi"
- REM 替换文件
- (
- for /f "usebackq delims=" %%i in ("%t1%") do (
- for /f "tokens=1* delims==" %%a in ("%%i") do (
- set "a=%%a"
- REM TitleList.ContextNumber查找并替换
- if "!a:~0,24!"=="TitleList.ContextNumber." (
- ( for /f "tokens=3" %%c in ('findstr /e /C:"\/\/!ctx%%~xa!" "%t2%" 2^>nul') do echo %%a=%%c ) || echo %%i
- ) else (
- REM TitleList.Url保存*.html
- if "!a:~0,14!"=="TitleList.Url." set "ctx%%~xa=%%b"
- echo %%i
- )
- )
- )
- ) > "%new_file%"
- pause&exit
复制代码
|