- @echo off
- dir /b *.txt | find /v /c "" > .tmp
- set /p Total=< .tmp
-
- find /v /c "" *.txt > .tmp
-
- for /f "delims=: tokens=1,2" %%a in (.tmp) do call :1 "%%a" %%b
- del .tmp
- exit /b
-
- :1
- set /a Last2 = %2 - 1, Count += 1
- set "File=%~1"
- findstr /n .* "%File:~11%" > .tmp
- (
- for /f "delims=" %%a in (.tmp) do (
- set Var=%%a
- set /a Line = Var
- SetLocal EnableDelayedExpansion
- if !Line! lss %Last2% (
- echo,!Var:*:=!
- ) else (
- if !Line! equ %Last2% if "!Var:*:=!" neq "" echo,!Var:*:=!
- )
- EndLocal
- )
- ) > "%File:~11%"
- cls
- echo 已处理 %Count% 个文件(共 %Total% 个)
复制代码
|