计算Windows下目录大小

统计当前目录下各文件夹的大小,在Linux下面比较简单,一个 du -sh * 命令就基本解决问题了
包括子目录du -c -s -m 以兆为单位显示总大小
win下一个个去点属性R就好悲剧。有类似软件:TreeSize等。
微调了下别人的批处理:http://blog.csdn.net/wmnothing/article/details/6590376
直接运行计算当前目录,也可以传目录参数

@echo off

set dpath=%1
IF [%1]==[] set dpath=%cd%
if NOT exist "%dpath%" (ECHO "%dpath%" path not exist & GOTO END)

:DIR_PATH

dir /ad /b "%dpath%" > 1.txt

setlocal enabledelayedexpansion

for /f "tokens=*" %%i in (1.txt) do (
dir /s "%dpath%\%%i" |findstr 个文件 > 2.txt || echo. > 2.txt
for /f "eol=0 tokens=1,3 " %%j in (2.txt) do (
set blank=
set format=
set size=%%k!blank!
set count=%%j!format!
set ll=!size:~0,15!字节 !count:~0,5!个文件 %%i
)
echo !ll!
)

del 1.txt 2.txt
GOTO END

:USAGE
echo Usage: %0 dir_path
GOTO END

:END
pause

原文地址:https://www.cnblogs.com/xiao0913/p/5113695.html