JSI Tip 10277. How can a script determine the size of a folder, using Microsoft public domain software?

Jerold Schulman

March 15, 2006

1 Min Read
ITPro Today logo

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

Where:

FolderPath is the path to the folder you wish to enumerate.Size       is a call directed environment variable that will contain the number of bytes.

FolderSize.bat contains:

@echo offif {%2}=={} @echo Syntax: FolderSize FolderPath Size&goto :EOFif not exist %1 @echo Syntax: FolderSize FolderPath Size - %1 not found.&goto :EOFfor /f "Tokens=2" %%a in ('diruse /s /b /d /q:999999999999999999999 %1^|find " TOTAL:"') do ( set %2=%%a)



Read more about:

Microsoft
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like