本帖最后由 smss 于 2020-5-28 01:07 编辑
- @echo off&setlocal enabledelayedexpansion&set m=1048576
- (for /f "tokens=*" %%i in ('dir /ad /b') do (set size=000
- for /f "eol=0tokens=3" %%j in ('dir /s/a/-c "%%i" 2^>nul^| findstr /i "个文件.*字节$"') do set "size=%%j00"
- if !size! geq 102400 (if !size! geq 104857600 (set s=MB&set t=!size!&set len=!t:~9!98765432100&set /alen=9+!len:~10,1!&set/a "r=!t:~,8!%%m,size=!t:~,8!/m"
- for /l %%j in (8 1 !len!) do set/a "q=!r!!t:~%%j,1!/m,r=!r!!t:~%%j,1!%%m"&set "size=!size!!q!"
- if !size! geq 102400 set s=GB&set /asize/=1024)else set s=KB&set /asize/=1024)else set s=Byte
- if "!size!" GTR "5" echo %%i !size:~,-2!.!size:~-2! !s!))>结果.TXT&start "" 结果.TXT&pause
复制代码 参考http://www.bathome.net/thread-31593-1-1.html http://bbs.bathome.net/viewthread.php?tid=25682 |