Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject count

Status
Not open for further replies.

nickdel

Programmer
May 11, 2006
367
GB
I'm using the following code to perform a recursive loop in order to get a total count of all files contained within a parent folder and it's sub folders.

Code:
Sub CountFiles(OfFolder As Scripting.Folder)

    Dim SubFolder As Scripting.Folder
    
    FileCount = FileCount + OfFolder.Files.Count

    
    For Each SubFolder In OfFolder.SubFolders
        CountFiles OfFolder:=SubFolder
    Next SubFolder
End Sub

I know there are about 400000 files in total however this code takes forever to perform the task. Going to the folder properties returns this information in a fraction of the time.

Is there a quicker way?

Thanks

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top