回复 1# zllk
可用第3方工具gawk ( http://bcn.bathome.net/tool/4.1.0/gawk.exe )来实现。
bat脚本方式如下:- @echo off
- cd /d "%~dp0"
- for /f "usebackq delims=" %%a IN (`dir/b *.srt^|findstr /RE /V "\.P[0-9][0-9]*\.srt"`) DO @awk -v"RS=\n[ \t]*\n" "FNR==1{p=0;Fn=substr(FILENAME,1,length(FILENAME)-4) \".P\";fe=\".srt\"}FNR%%3==1{p++}{print $0,ORS>(Fn P p fe)}" %%a
复制代码 命令行方式如下- for /f "usebackq delims=" %a IN (`dir/b *.srt^|findstr /RE /V "\.P[0-9][0-9]*\.srt"`) DO @awk -v"RS=\n[ \t]*\n" "FNR==1{p=0;Fn=substr(FILENAME,1,length(FILENAME)-4) \".P\";fe=\".srt\"}FNR%3==1{p++}{print $0,ORS>(Fn P p fe)}" %a
复制代码
|