Created
February 15, 2017 05:27
-
-
Save ndthanh/ad430c4c4516c8233f5745ae54d8e789 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function fCount(strPath) | |
Dim fCnt As Integer | |
fCnt = ShowFolderList(strPath) | |
fCount = fCnt | |
End Function | |
Sub CntFiles() | |
Dim strPath As String | |
strPath = "A:\Asif\Answers\abc" | |
ShowFolderList (strPath) | |
End Sub | |
Function ShowFolderList(Path) | |
Dim fso, folder, subFlds, fld | |
Dim tFiles As Integer | |
tFiles = ShowFilesList(Path) | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set folder = fso.GetFolder(Path) | |
Set subFlds = folder.SubFolders | |
For Each fld In subFlds | |
If fld.Name = "Entered" Then | |
GoTo SkipFld: | |
Else | |
Path = fld.Path | |
tFiles = tFiles + ShowFilesList(Path) | |
End If | |
SkipFld: | |
Next | |
'MsgBox tFiles & " files" | |
ShowFolderList = tFiles | |
End Function | |
Function ShowFilesList(folderspec) | |
Dim fso, f, f1, fc, s | |
Dim Cnt As Integer | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set f = fso.GetFolder(folderspec) | |
Set fc = f.Files | |
ShowFilesList = fc.Count | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment