NOTE: See How can a script determine the size of a folder, using standard commands?

Using Diruse.exe, in the public domain, because it runs much faster, I have scripted FolderSize.bat to determine the size of a folder, including all sub-folders and files.

The syntax for using FolderSize.bat is:

Call FolderSize FolderPath Size


<b>FolderPath</b> is the path to the folder you wish to enumerate.

<b>Size</b>       is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain the number of bytes.
FolderSize.bat contains:
@echo off
if \{%2\}==\{\} @echo Syntax: FolderSize FolderPath Size&goto :EOF
if not exist %1 @echo Syntax: FolderSize FolderPath Size - %1 not found.&goto :EOF
for /f "Tokens=2" %%a in ('diruse /s /b /d /q:999999999999999999999 %1^|find " TOTAL:"') do (
 set %2=%%a