Pages

Friday, March 4

Count number of files in a folder

Dim iFileCount, FolderName, vFiles, objFSO
iFileCount = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FolderName = objFSO.GetFolder("C:\Desktop") ' Folder Path
Set vFiles =FolderName.Files

For each vFile in vFiles
    Print vFile
    iFileCount = iFileCount + 1
Next
msgbox iFileCount






Above code will print names of all the file in given folder and display the total count of files.

2 comments:

  1. Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. word counter

    ReplyDelete