Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
I deleted 99% of data from excel file. Folder Size remains unchang msnut Excel Discussion (Misc queries) 2 September 21st 05 01:44 PM
open file from folder save in new folder tim64[_3_] Excel Programming 20 June 17th 05 07:58 PM
Folder Size Andibevan[_2_] Excel Programming 3 June 1st 05 03:42 PM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM


All times are GMT +1. The time now is 01:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"