@echo off&cd/d "%~dp0"
setlocal enabledelayedexpansion
set "t1=2013/10"
set "t2=2014/12/15"
set "f= "
set "$0=文件名%f%日期 时间%f%名称"
(for /f "tokens=1,2* delims==:" %%a in (
'findstr "Date=20[0-9][0-9].[0-1][0-9].[0-3][0-9]" *.txt')do (
if "%%c" geq "%t1%" if "%%c" leq "%t2%99" (
set/a n+=1
>con echo %%a
for /f "delims=:" %%x in ('findstr/inc:"[TakeUpMiss]" "%%a"')do set/a Nmax=%%x
for /f "tokens=1* delims=:" %%d in ('findstr/n . "%%a"')do (
if %%d equ 1 for /f "tokens=2,3 delims=%f%" %%f in ("%%e")do (
if !n! equ 1 set "fd=%%f.xls"
set "s=%%c%f%%%~na%f%%%g")
if %%d equ 12 for /f "tokens=1* delims==" %%f in ("%%e")do (
if !n! equ 1 set "$=%$0%%f%%%f"
set "s=!s!%f%%%g")
if !n! equ 1 if %%d equ 19 set "$=!$!%f%%%e"
if %%d equ 20 for /f "tokens=*" %%f in ("%%e")do set "s=!s!%f%%%f"
if !n! equ 1 if %%d equ 31 for /f "tokens=5* delims=%f%" %%f in (
"%%e")do set "$=!$!%f%%%g"
if %%d geq 32 if %%d lss !Nmax! (
for /f "tokens=5* delims=%f%" %%f in ("%%e")do (
set/a m=0
if not "%%g"=="" for %%h in (%%g)do (
set/a "m+=1
if defined #!m! (set/a #!m!+=%%h)else set #!m!=%%h)
)))
for /l %%d in (1,1,!m!)do set "s=!s!%f%!#%%d!"&set "#%%d="
echo;!S!)))>temp.txt
(echo;!$!
for /f "tokens=1,2* delims=%f%" %%i in ('type temp.txt^|sort')do (
echo %%j%f%%%i%f%%%k))>"%fd%"
del temp.txt
echo %n% 个文件统计完毕!
pause