Skip navigation

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

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 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
)



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish