Created
October 16, 2016 08:24
-
-
Save jorben/c08010a6f887946fd8f0ecd2fa24d5b0 to your computer and use it in GitHub Desktop.
windws 下统计指定目标路径下各文件夹的大小
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
IF [%1]==[] GOTO USAGE | |
if NOT exist "%1" (ECHO "%1" path not exist & GOTO END) | |
:DIR_PATH | |
dir /ad /b %1 > 1.txt | |
setlocal enabledelayedexpansion | |
for /f "tokens=*" %%i in (1.txt) do ( | |
rem echo | |
dir /s "%1\%%i" |findstr 个文件 > 2.txt || echo. > 2.txt | |
rem for /f "eol=0 tokens=1,3 " %%j in (2.txt) do set ll=%%k 字节 %1\%%i %%j 个文件 | |
for /f "eol=0 tokens=1,3 " %%j in (2.txt) do set ll=%%k & set ll=!ll:~0,-9! M %1\%%i %%j 个文件 | |
echo !ll! | |
rem echo. | |
) | |
set total= | |
Endlocal | |
del 1.txt 2.txt | |
GOTO END | |
:USAGE | |
echo Usage: %0 dir_path | |
GOTO END | |
:END | |
rem pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用举例: 计算C盘Windows目录下各文件夹的大小
拷贝 win_dush.bat到C盘
执行 win_dush.bat Windows