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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need vbscript to check folder size

Status
Not open for further replies.

jlotz1

Technical User
Feb 1, 2010
6
US
Hello everyone.

I need a script that will tell me the size of approximately 1500 home directories. What I'd like as output is an Excel spreadsheet with the folder name and the size (in MB, preferably).

I found some scripts that'd do the job, but they report on EVERY subdirectory in each home dir, which makes the report MASSIVE. What I want is just the top level folder name and it's size, nothing more.

Can anyone help?

Thank you!
 
strTargetFolder = "u:\users" 'you could pass this as a command line argument?
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(strTargetFolder) Then
Wscript.Echo "found " & strTargetFolder
Wscript.Echo "will bind to it and enumerate subfolders"
Set objFolder = FSO.GetFolder("u:\users")
For Each aFolder In objFolder.SubFolders
Wscript.Echo aFolder.Name & ";" & aFolder.Size
Next
Set objFolder = Nothing
Else
Wscript.Echo "cannot find " & strTargetFolder
End If
Set FSO = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top