Re: Report total file size

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ray at <%=sLocation%> [MVP] (%=sLocation%)
Date: 08/18/04


Date: Tue, 17 Aug 2004 23:55:16 -0400

This will output the results into a CSV file, which may be a bit more
friendly, as when you loop through a subdir collection, they are not
necessarily looped through in an alphabetical order.

Const ROOT_DIR = "C:\Path"
Const RESULTS_FILE = "C:\results.csv"

Dim oFSO
Dim oRootDir, oSubdir
Dim sOutput, dblTotal

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oRootDir = oFSO.GetFolder(ROOT_DIR)
dblTotal = 0
For Each oSubDir In oRootDir.Subfolders
 sOutput = sOutput & oSubdir.Name & "," & oSubdir.Size & vbCrLf
 dblTotal = dblTotal + oSubdir.Size
Next
Set oRootDir = Nothing

sOutput = sOutput & "Total," & CStr(dblTotal)
oFSO.CreateTextFile(RESULTS_FILE).Write sOutput
Set oFSO = Nothing

Ray at home

"Jamie Jenkins" <jjenkins@american-appraisal.com> wrote in message
news:c611f9bf.0408171406.60877da8@posting.google.com...
> I'm very new to scripting, and need to create a VBS script that will
> "spider" through a server and report the total in each main folder.
> The folder structure looks like this:
>
> Main Share
> ----\ User1
> ---------\directory1
> ---------\directory2
> ---------\directory....
> ----\ User2
> ---------\directory1
> ---------\directory2
> ---------\directory....
> ----\ User3
> ---------\directory1
> ---------\directory2
> ---------\directory....
>
> I need an output file that would then look line this:
>
> Main Share
> User1 xxx,xxx,xxx
> User2 xxx,xxx,xxx
> User3 xxx,xxx,xxx
> =====================
> Total xxx,xxx,xxx
>
> Can anyone help me out?
>
>
> Thanks.



Relevant Pages

  • Scanning for last modified date
    ... We have a server that is for company-wide backups. ... Dim WshNetwork ... Set oFSO = CreateObject ... Set oRootDir = oFSO.GetFolder ...
    (microsoft.public.scripting.wsh)
  • Re: Adding bookmarks in VBA in a specific place
    ... Dim oOutFile, oFSO ... Dim oRange As Range ... Set oFSO = CreateObject ... Private Sub InsertBookmark ...
    (microsoft.public.word.vba.beginners)
  • Re: Kill Function by author
    ... Sub LoopFolders() ... Set oFSO = CreateObject ... Dim Folder As Object ... DocProps = CVErr ...
    (microsoft.public.excel.programming)
  • Re: vbscript snipit to modify text strings in a csv file
    ... Set oFSO = CreateObject ... sRead = LCase ... script to pull the user data from the csv file the logparser tool creates, ... so the username only remains as well as any rows that have an empty 1st cell. ...
    (microsoft.public.windows.server.scripting)
  • API calls dont work; FSO does?
    ... but the FSO file object returns the correct creation date. ... Dim oFSO As Scripting.FileSystemObject ... Set oFSO = New Scripting.FileSystemObject ... Set oFil = oFSO.GetFile ...
    (microsoft.public.vb.general.discussion)