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

Files & Size under each sub-folder.

Status
Not open for further replies.

logicacmg000

Technical User
Sep 30, 2004
75
US
On a server there are 60GB of data and I want to check under each sub-folder what files there are and their sizes. What is the best and easiest way to do this on W2k3.

Thanks.
 
Here is a script to do it
Code:
'==========================================================================
'
' NAME: <filename>
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 12/23/2003
'
' COMMENT: <comment>
'
'==========================================================================

'Check all subfolders below given folder for size over a minimum size.
Dim FolderPath
Dim FolderSize
Dim MinSize

Set objArgs=WScript.Arguments
FolderPath=objArgs(0)
MinSize=CLng(objArgs(1)) 

Const CONVERSION_FACTOR = 1048576 'converts folder size to MB
'Const MinSize = 100 'set minimum folder size in MB.
If Wscript.Arguments.count = 0 Then
    Wscript.Echo "Usage: foldersize.vbs [folder][minimum size]"
    Wscript.Echo "Example: foldersize.vbs c:\myfolder 50"
    Wscript.Quit
End If

'FolderPath = Wscript.Arguments(0)
'MinSize = Wscript.Arguments(1)
report = "Folder Size" & vbTab &"Folder Name" & vbCrLf
Set FSO = CreateObject ("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder(FolderPath)
MsgBox Report
Sub ShowSubFolders (Folder)
    For Each SubFolder In Folder.SubFolders 
    FolderSize = SubFolder.Size / CONVERSION_FACTOR
        If FolderSize >  MinSize Then
            report = report & int(FolderSize) & vbTab & vbTab & SubFolder.Path & vbCrLf
        End If
        ShowSubFolders SubFolder
    Next

End Sub

This script will dump similar info to Excel
Code:
'==========================================================================
'
' NAME: getFolderSizes2XL.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 11/21/2004
'
' COMMENT: <comment>
'
'==========================================================================
Dim oFS, oFolder
Dim objexcel, r, lnameArray, lname, nameLength
set oFS = WScript.CreateObject("Scripting.FileSystemObject")
set oFolder = oFS.GetFolder("C:\Documents and Settings")

Set objExcel = createobject("Excel.application")   
objexcel.Workbooks.add
objexcel.Cells(1, 1).Value = "Folder Name"
objexcel.Cells(1, 2).Value = "Size (MB)"
objexcel.Cells(1, 3).Value = "# Files"
objexcel.Cells(1, 4).Value = "# Sub Folders"
objexcel.Visible = True
Wscript.Sleep 300
r=2


ShowFolderDetails oFolder, r

	
	
'	objexcel.ActiveWorkbook.SaveAs("LogonReport.xls")
'	objexcel.Quit
MsgBox "Done"	
	
Function ShowFolderDetails(oF,r)
	Dim F
    objexcel.Cells(r, 1).Value = oF.Name
    objexcel.Cells(r, 2).Value = oF.Size /1024\1024
    objexcel.Cells(r, 3).Value =  oF.Files.Count
    objexcel.Cells(r, 4).Value =  oF.Subfolders.count
    r = r+1
    for each F in oF.Subfolders
        ShowFolderDetails F, r
    next
End Function

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top