Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Diskspace by directory 1

Status
Not open for further replies.

TheLad

Technical User
Aug 3, 2001
3,846
GB
Guys

I am trying to establish if I can get diskspace results by directory using a script. I have tried looking in Scriptomatic but I cannot find what I am looking for.

Basically, I would like a script that I can give a base directory to (eg. E:\Users) and that script will examine the sub-directories underneath the base directory and give me the diskspace used by each individual immediate subdirectories and their contents eg. E:\Users\User1 = 1Mb, E:\Users\User2 = 2Mb etc...)

Please can anyone point me in the right direction?

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Using the FileSystemObject...
Code:
dim fso, fldr, subfldr, sFolderToCheck
sFolderToCheck = "E:\Users"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.GetFolder(sFolderToCheck)
For Each subfldr in fldr.Subfolders
	wscript.echo "size of " & subfldr.name & " is " & subfldr.size & " bytes."
Next
wscript.echo "the whole root folder (" & sFolderToCheck  & ") is " & fldr.size & " bytes."
 
Great script, thanks for your reply (have a star!)



--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top