Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Folder Size/File Count
Hi All
I know how to get the size of a Folder and work out the size of Files within that Folder. What I would to do is to get the Total Files, Total Folders and Total Size of a Sub Set of Folders without having to scan through them. Like with Windows Explorer you can right click on a Folder and bring up the Properites. We are analysising the information in Excel. Many Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Folder Size/File Count
Hi DMc2004,
You can use the FileSystemObject (part of the Microsoft Scripting Runtime library) to do this type of thing: Public Function glGetFolderSizeInMB(rsPath As String) As Long Dim objFSO As Object Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(rsPath) Then glGetFolderSizeInMB = objFSO.getfolder(rsPath _ ).Size / (1024 ^ 2) End If Set objFSO = Nothing End Function Public Function glGetFileCount(rsFolderPath As String) As Long Dim objFSO As Object Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(rsFolderPath) Then glGetFileCount = objFSO.getfolder(rsFolderPath _ ).Files.Count End If Set objFSO = Nothing End Function Public Function glGetSubfolderCount(rsFolderPath As String) As Long Dim objFSO As Object Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(rsFolderPath) Then glGetSubfolderCount = objFSO.getfolder(rsFolderPath _ ).Subfolders.Count End If Set objFSO = Nothing End Function These all use late binding, so there's no need for a reference to the library. But if you want to play around with the FSO object model a bit, you could set a reference to Microsoft Scripting Runtime via Tools | References in the VBE (and Dim the object as Scripting.FileSystemObject) - that way, you'll get the intelisense. -- Regards, Jake Marx www.longhead.com [please keep replies in the newsgroup - email address unmonitored] DMc2004 wrote: Hi All I know how to get the size of a Folder and work out the size of Files within that Folder. What I would to do is to get the Total Files, Total Folders and Total Size of a Sub Set of Folders without having to scan through them. Like with Windows Explorer you can right click on a Folder and bring up the Properites. We are analysising the information in Excel. Many Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Folder Size/File Count
If you want a fast API method:
http://groups.google.co.uk/group/mic...a70685aa576333 NickHK "DMc2004" wrote in message ... Hi All I know how to get the size of a Folder and work out the size of Files within that Folder. What I would to do is to get the Total Files, Total Folders and Total Size of a Sub Set of Folders without having to scan through them. Like with Windows Explorer you can right click on a Folder and bring up the Properites. We are analysising the information in Excel. Many Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
I deleted 99% of data from excel file. Folder Size remains unchang | Excel Discussion (Misc queries) | |||
open file from folder save in new folder | Excel Programming | |||
Folder Size | Excel Programming | |||
Create Folder and Text File in folder | Excel Programming |