- @echo off
- chcp 65001 >nul
- rem 批处理保存为utf-8编码格式
- cd /d "%~dp0"
- for /f "delims=" %%i in ('dir /b /a-d *.txt') do (
- setlocal
- for /f "tokens=1 delims=[]" %%a in ('find /n "=== 第" ^<"%%i" ^|find "章"') do (
- set #%%a=1
- )
- (for /f "tokens=1* delims=[]" %%a in ('find /n /v "" ^<"%%i"') do (
- if defined #%%a (
- for /f "tokens=1* delims=章" %%x in ("%%b") do (
- echo %%x章 %%y
- )
- ) else (
- echo=%%b
- )
- ))>$
- move $ "%%i"
- endlocal
- )
- pause
复制代码
|