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

check folder size one by one

Status
Not open for further replies.

createscript

Technical User
Jul 21, 2010
1
HK
Dear all,

Here is need you help, the script use to check for each folder size and output to csv format.

The script run to check all the folder size
e:\packages$\install\KBXXX\XXXX\XXX. It is because the Microsoft KB has other sub-directory. I have no idea how to write the code which can run the size of sub-directory for each and output the size and folder name.

Below is the code

Const ForAppending = 8

Set fso = CreateObject("Scripting.FileSystemObject")
Set fs = fso_OpenTextFile("c:\temp\DirSize.csv", ForAppending, True)

Do
WScript.StdOut.Write "Please enter directory name: "
strFolder = WScript.StdIn.ReadLine
If fso.FolderExists(strFolder) Then
Exit Do
Else
WScript.StdOut.Write "Invalid Directory ... Try Again" & vbCrLf
End If
Loop

Set f = fso.GetFolder(strFolder)
WScript.Echo f.Path & ": " & FormatNumber((f.Size / 1048576),4,,TriStateTrue) & " Bytes"
fs.WriteLine f.Path & "," & Replace(FormatNumber((f.Size / 1048576),4), ",", "")
fs.Close

Anyone expert can help me to solve the probelm

Thank you very much
 
A starting point:
Code:
Set f = fso.GetFolder(strFolder)
For Each sf In f.SubFolders
  fs.WriteLine sf.Path & "," & Replace(FormatNumber((sf.Size / 1048576),4), ",", "")
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top