Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an external disk that is connected to a LAN network.
I want to find the disk usage of a directory on the disk from a script. I looked at power shell and SysInternals tools but couldn't find any solution. Any ideas?


share|improve this question
add comment

4 Answers

up vote 8 down vote accepted

Powershell makes it possible in the following way:

Size in MB

"Folder use {0:0,0.00} MB" -f (((Get-ChildItem -R C:\TEMP | measure-object length -Sum ).Sum / 1MB)

Size in GB

"Folder use {0:0,0.00} MB" -f (((Get-ChildItem -R C:\TEMP | measure-object length -Sum ).Sum / 1GB)

Maybe in TB

"Folder use {0:0,0.00} MB" -f (((Get-ChildItem -R C:\TEMP | measure-object length -Sum ).Sum / 1TB)
share|improve this answer
This works well, "Folder use 121.79 MB." You can also use 1KB in place of 1024. –  Bratch Sep 14 '09 at 16:15
add comment

You could try any of the TreeSize type tools, for instance http://dev.carl-thomas.net/Utils/TreeSize/index.htm

share|improve this answer
Thanks for all the other posts. The answers where good but this one is exactly what I need. –  Ohad Horesh Sep 15 '09 at 7:00
add comment

There is also a Microsoft Tool called Diruse.

D:\Webmaster\cmd>diruse.exe C:\temp /M /*

Size (mb)  Files  Directory
   501.75    138  SUB-TOTAL: C:\TEMP\Garbadge
   501.75    138  TOTAL: C:\TEMP\Garbadge

You can find more about diruse here

share|improve this answer
add comment

Cygwin's du will do the trick as well.

$ /bin/du 'C:\WINDOWS\system32' | sort -rn | head -20
1104392 C:\WINDOWS\system32
194127  C:\WINDOWS\system32/dllcache
61675   C:\WINDOWS\system32/spool
61284   C:\WINDOWS\system32/config
57336   C:\WINDOWS\system32/ReinstallBackups
54572   C:\WINDOWS\system32/ReinstallBackups/0020/DriverFiles
54572   C:\WINDOWS\system32/ReinstallBackups/0020
51952   C:\WINDOWS\system32/mui
51590   C:\WINDOWS\system32/wbem
48765   C:\WINDOWS\system32/spool/drivers
48573   C:\WINDOWS\system32/spool/drivers/w32x86
43233   C:\WINDOWS\system32/spool/drivers/w32x86/3
33102   C:\WINDOWS\system32/drivers
21610   C:\WINDOWS\system32/wbem/Repository
21609   C:\WINDOWS\system32/wbem/Repository/FS
12030   C:\WINDOWS\system32/spool/XPSEP
10244   C:\WINDOWS\system32/wbem/AutoRecover
9890    C:\WINDOWS\system32/CatRoot
9889    C:\WINDOWS\system32/CatRoot/{F750E6C3-38EE-11D1-85E5-00C04FC295EE}
9770    C:\WINDOWS\system32/CatRoot2

There you go: the twenty largest directory sizes (in K).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.