+ Reply to Thread
Results 1 to 3 of 3

Folder Size/File Count

  1. #1
    DMc2004
    Guest

    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. #2
    Jake Marx
    Guest

    Re: 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. #3
    NickHK
    Guest

    Re: Folder Size/File Count

    If you want a fast API method:
    http://groups.google.co.uk/group/mic...a70685aa576333

    NickHK

    "DMc2004" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1