×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

List File Size Script

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"

RE: List File Size Script

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: 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

(OP)
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

RE: List File Size Script

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 http://www.thespidersparlor.com/vbscript

RE: List File Size Script

(OP)
That worked Mark!!!

Thanks Again

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close