List File Size Script
List File Size Script
(OP)
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"
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"
RE: List File Size Script
CODE
'
' NAME: ReportMP3.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' 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 http://www.thespidersparlor.com/vbscript
RE: List File Size Script
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
RE: List File Size Script
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 http://www.thespidersparlor.com/vbscript
RE: List File Size Script
Thanks Again