Windows – Free tool/script for directory size calculation

directorywindows

Does anyone know of a free command-line tool or script that calculates the size of a directory including all subdirectories?

It needs to be compatible with Windows 7, work with hard links and junctions and gracefully deal with access denied to some subfolder (i.e. continues in such a case).

I could not find anything and am thinking of writing my own tool.

Update:

I am looking for something to analyze (many) roaming user profiles stored on a file server. The perfect tool would make it easy to find the largest profile directories or those with the most files.

Best Answer

Du by Sysinternals might be what you're looking for. It's free from Microsoft, and it's basically a rudimentary version of the *ix du. It deals with junctions and denied permissions by reporting the file doesn't exist.

http://technet.microsoft.com/en-us/sysinternals/bb896651

Du v1.34 - report directory disk usage
Copyright (C) 2005-2009 Mark Russinovich
Sysinternals - www.sysinternals.com

usage: du [[-v] [-l <levels>] | [-n]] [-q] <directory>
   -l     Specify subdirectory depth of information (default is all levels)
   -n     Do not recurse.
   -q     Quiet (no banner).
   -u     Count only unique file occurences.
   -v     Show size (in KB) of intermediate directories.

c:\sysinternals>du c:\sysinternals

Du v1.34 - report directory disk usage
Copyright (C) 2005-2009 Mark Russinovich
Sysinternals - www.sysinternals.com

Files:        101
Directories:  0
Size:         32,798,999 bytes
Size on disk: 32,798,999 bytes