Search code examples
windowsdirectorysize

Size of a directory in Windows


Is there a command to get the size of a directory in Windows? The result should only give the size and nothing else. The command dir gives a lot of information.


Solution

  • @echo off
    setLocal EnableDelayedExpansion
    set /a value=0
    set /a sum=0
    FOR /R %1 %%I IN (*) DO (
    set /a value=%%~zI/1024
    set /a sum=!sum!+!value!
    )
    @echo !sum!