用了一个取巧的方法~- @echo off&setlocal enabledelayedexpansion
- set "t=%time%"
- set "desfolder=f:\111"
- set "s=%desfolder%"
- :lp
- if defined s set/a y+=1&set "s=%s:~1%"&goto lp
- for /f "skip=2 tokens=1,2,3*" %%a in ('dir/s/tc/a-d %desfolder%\*.*') do (
- set "var=%%a"
- if /i "!var:~,%y%!" equ "%desfolder%" (
- set "str=%%a"
- ) else (
- set/a n+=1,x=n%%11
- if !x! neq 0 set/a s+=1
- if !n! lss 1100 if !x! neq 0 echo %%a %%b !str!\%%d
- ))
- set/a s-=3
- echo %s%个文件
- call :time0 "%t%" "%time%" "ok"
- echo.&echo 耗时: %ok%
- pause&exit/b
- :time0 以下为封装部分。
- :: code 随风 @bbs.bathone.cn 2008-08-15
- setlocal&set /a n=0
- for /f "tokens=1-8 delims=.: " %%a in ("%~1:%~2") do (
- set /a n+=10%%a%%100*360000+10%%b%%100*6000+10%%c%%100*100+10%%d%%100
- set /a n-=10%%e%%100*360000+10%%f%%100*6000+10%%g%%100*100+10%%h%%100
- )
- set "n=%n:-=%"
- set /a s=n/360000,n=n%%360000,f=n/6000,n=n%%6000,m=n/100,n=n%%100
- set "ok=%s% 小时 %f% 分钟 %m% 秒 %n% 毫秒"
- endlocal&set "%~3=%ok%"&goto :eof
复制代码
|