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

Directory Size

Status
Not open for further replies.

JH123

Technical User
Mar 26, 2001
12
US
I am familiar with VBScript but I haven't used it in about 2 years so I'm a bit rusty. I need a script to find the name and size of multiple directories.

As an example the directory path would be
d:/users/user1/profiles
d:/users/user2/profiles

I need to know the name of user1 and the size of the profiles directory and then the same for user2. There are about 100 different user directories that I'll need to go through.
Thanks
 
Try something like this:

Dim filesys, folder, folders, subfolder

Set filesys = CreateObject("scripting.filesystemobject")
Set folders = filesys.getfolder("d:\users")

For Each folder In folders.subfolders
Set subfolder = filesys.GetFolder(folder.Path & "\profiles")
wscript.echo subfolder.path & vbcrlf & subfolder.Size
next

Dana Hallenbeck
 
Perfect thank you. But how to I write the results to a file instead?
 
Try something like:
set logfile = filesys.opentextfile("location",1,True)

This is just the basic syntax. A good resource for basic information on writing or manipulating files is
good luck

dana hallenbeck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top