Get Total File Size of All Files In Folder

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Get Total File Size of All Files In Folder

Post by RNIB » Fri Oct 25, 2024 9:37 am

I need to find what the overall total byte size is of all files within a folder but the number of files, file types and file names will be different each time.

Is there a way I can do this simply, something along the lines of:

FileSize>C:\Temp\*.*,nFileSize

Or do I need to count the number of files, capture all the file names in an array, extract each file name, get the filesize of each file and add the result together each time?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Get Total File Size of All Files In Folder

Post by JRL » Fri Oct 25, 2024 2:01 pm

Code: Select all

VBSTART
  Function GetFolderSize(Path)
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     Set objFolder = objFSO.GetFolder(Path)
     GetFolderSize = objFolder.Size
  End Function
VBEND
VBEval>GetFolderSize("c:\temp"),fSize

MDL>fSize
Posted HERE by RNIB back in November 2017

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts