- @echo off&setlocal enabledelayedexpansion
- set "f=f:\111\测试文件夹"
- set t=%time%
- for /f "skip=3 tokens=1,2,3*" %%i in ('dir/s/tc/a-d "%f%\*.*"') do (
- if defined x echo !x! %%i %%j&goto ok
- if "%%i"=="所列文件总数:" set x=%%i
- set str=%%i
- if "!str:~1,2!"==":\" (set ph=%%i)else if not defined x if not "%%j"=="个文件" echo !ph!\%%l %%i %%j
- )
- :ok
- call :time0 "%t%" "%time%" "ok"
- echo.&echo 耗时: %ok%
- pause&exit
- :time0
- 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
复制代码
- @echo off&setlocal enabledelayedexpansion
- set "f=f:\111\测试文件夹"
- set t=%time%
- for /f "skip=3 tokens=1,2,3*" %%i in ('dir/s/tc/a-d "%f%\*.*"') do (
- set str=%%i
- set var=%%j
- if "!str:~1,2!"==":\" (set ph=%%i)else if "!var:~2,1!"==":" echo !ph!\%%l %%i %%j&set /a n+=1
- )
- echo 文件总数: %n%
- call :time0 "%t%" "%time%" "ok"
- echo.&echo 耗时: %ok%
- pause&exit
- :time0
- 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
复制代码
[ 本帖最后由 terse 于 2008-10-3 09:45 编辑 ] |