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!

List File Size Script 1

Status
Not open for further replies.

pbanacos

IS-IT--Management
Apr 21, 2006
34
US
Hello,

The script below is searching for specific files and memory usage on my system. Is there a way to just make this display the total file size.

Thanks in adavance!
-------------------------------------

Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /c c: & dir /s /w *.m4a *.mp3 *.wmv .wma >Music.txt "_
& " & notepad music.txt
 
A scaled down version of what I offered in the OTHER thread you posted on this.

Code:
'==========================================================================
'
' NAME: ReportMP3.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 8/28/2006
'
' COMMENT: <comment>
'
'==========================================================================

'---------------------------------------------------------------------------------------
'
'	Name:		getfoldersize.vbs
'	Version:	1.0
'	Date:		3/1/2004
'	Author:		Mark D. MacLachlan
'	Description:	getfoldersize.vbs calculates the size of all subfolders within
'			a folder
'	
'---------------------------------------------------------------------------------------
Dim Sizereport, FSO

Set FSO = CreateObject("SCripting.FileSystemObject")
   rootfolder = Inputbox("Enter directory/foldername: " & _
                         chr(10) & chr(10) & "(i.e. C:\Program Files or " & _
                         "\\Servername\C$\Program Files)" & chr(10) & chr(10), _
                         "Getfoldersize", "C:\")

   
report = ""


'Run checkfolder
MP3SizeReport = CheckFolder(rootfolder, 0)

Function CheckFolder(objCurrentFolder, SizeReport)
      Set oFolder = fso.GetFolder(objCurrentFolder)
      For Each oFile In oFolder.files
		   	If oFile.Type = "MP3 Format Sound" Then
		    	SizeReport = SizeReport + oFile.Size
		    End If
	  Next
    
    'Recurse through all of the folders
    For Each objNewFolder In oFolder.subFolders
        CheckFolder objNewFolder, SizeReport
    Next
    CheckFolder = SizeReport
End Function

Report = Report & vbCrLf & "Total MP3 Size =" & (MP3SizeReport/1024\1024) & "MB"

MsgBox Report

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Thanks for the post Mark that was a great help.

I have one more newbie question...

If I wanted to search for multiple file types should I use an IF statement with || or && "M4A", "Windows Media Audio" etc.

Is that even possible to search for multiple file types?

Thanks for the post again!

Paul
 
You could switch out the If statement:

If oFile.Type = "MP3 Format Sound" Then
SizeReport = SizeReport + oFile.Size
End If

And replace with a Select Case

Select Case oFile.Type
Case "MP3 Format Sound", "Windows Media Audio"
SizeReport = SizeReport + oFile.Size
End Select

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top