网上摘抄 枚举子文件大小 批处理方式
@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