@ECHO OFF :: Display the disk space in MB used by the subdirectories :: of the directory represented by %1, plus a grand total PUSHD "%~1" SETLOCAL ENABLEDELAYEDEXPANSION SET Total=0 FOR /D %%A IN (*) DO ( SET DirSize=0 FOR /F "tokens=1,3" %%B IN ('DIR /A-D /-C /S "%%~A"') DO ( IF %%B NEQ 0 SET DirSize=%%C ) IF !DirSize! GTR 0 ( FOR /F %%B IN ('powershell -C "!Total! + !DirSize!"') DO SET Total=%%B FOR /F "delims=" %%B IN ('powershell -C "\""{0,12:F2}\"" -f ( !DirSize! / 1MB )"') DO SET DirSize=%%B ) ECHO.!DirSize! MB %%~fA ) ECHO. FOR /F "delims=" %%A IN ('powershell -C "\""{0,12:F2}\"" -f ( %Total% / 1MB )"') DO SET Total=%%A ECHO.%Total% MB Total ENDLOCAL POPD