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

Folder Size script seen several but not for my situation

Status
Not open for further replies.

ensing

Technical User
Apr 2, 2004
10
0
0
NL
I wan't to know the exact size in kb from several profiles directory's including the subdirs.
I have an M:\user1 , m:\user2 , m:user3 etc.
There are about 1600 userdirs and I wan't to know the size for 21 of them. It's nice if I can fill the usernames in a msgbox or manualy in the script.
If possible I wan't it reported in a logfile.

 
I tried below. But this one count's all files and not the folders. I don't know how to add the subfolders.

Dim NTusername
NTUsername = InputBox("Insert username")
dim fso, f, filesize1
dim totalsize

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(" M:\ & NTusername")
Set colFiles = F.Files
for each file in colfiles

totalsize = totalsize + file.size

next
wscript.echo formatNumber((totalsize/1048576), 0) & " Mb"
 
I don't think this line will work:

Set f = fso.GetFolder(" M:\ & NTusername")


But as for how to do all of the subfolders, you essentially need to put this code into a sub then have it recursively call itself. THere should be several examples of this if you search the forum for recursive.
 
Try simply this:
NTUsername = InputBox("Insert username")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(" M:\" & "NTusername")
WScript.Echo FormatNumber((f.Size/1048576), 0) & " Mb"


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top