2

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?

Thanks.

Ohad Horesh
  • 249
  • 2
  • 4
  • 7

4 Answers4

8

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)
Ivo Looser
  • 311
  • 1
  • 4
1

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

Posipiet
  • 644
  • 5
  • 4
0

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

Ivo Looser
  • 311
  • 1
  • 4
0

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

ordnungswidrig
  • 123
  • 1
  • 1
  • 6
reinierpost
  • 412
  • 3
  • 9