Private Sub SpanFolders(SourceFolderName As String, Optional ByVal FolderLevel = 0)
' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
'Dim FSO As Object 'Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder 'Scripting.Folder
Dim SubFolder As Scripting.Folder 'Scripting.Folder
Dim FileItem As Scripting.file 'Scripting.File
Dim ParentID As Long
FolderLevel = FolderLevel + 1
Set SourceFolder = FSO.GetFolder(SourceFolderName)
ParentID = GetParentID(SourceFolder.Name)
For Each SubFolder In SourceFolder.SubFolders
LogFilesFolders SubFolder.Name, SubFolder.Path, SubFolder.Type, ParentID, fft_Folder, FolderLevel
SpanFolders SubFolder.Path, FolderLevel
Next SubFolder
For Each FileItem In SourceFolder.Files
If (FileItem.Attributes And 2) <> 2 And (FileItem.Attributes And 4) <> 4 Then
LogFilesFolders FileItem.Name, FileItem.Path, FileItem.Type, ParentID, fft_File, FolderLevel
End If
Next FileItem
Set FileItem = Nothing
Set SourceFolder = Nothing
End Sub
Private Sub SpanFolderSummations(SourceFolderName As String, Optional ByVal FolderLevel = 0, Optional CountHiddenSystem As Boolean = False)
' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
'Dim FSO As Object 'Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder 'Scripting.Folder
Dim SubFolder As Scripting.Folder 'Scripting.Folder
Dim FileItem As Scripting.file 'Scripting.File
Dim ParentID As Long
Dim FolderCount As Long
Dim FileCount As Long
' Dim TotalFolderCount As Long
' Dim TotalFileCount As Long
FolderLevel = FolderLevel + 1
Set SourceFolder = FSO.GetFolder(SourceFolderName)
For Each SubFolder In SourceFolder.SubFolders
ParentID = GetCurrentID(SourceFolder.Name)
FolderCount = SubFolder.SubFolders.Count
If CountHiddenSystem Then
FileCount = SubFolder.Files.Count 'This will count hidden as well
Else
FileCount = 0
For Each FileItem In SubFolder.Files
If (FileItem.Attributes And 2) <> 2 And (FileItem.Attributes And 4) <> 4 Then
FileCount = FileCount + 1
End If
Next FileItem
End If
LogFolderSummations SubFolder.Name, SubFolder.Path, FolderCount, FileCount, ParentID, FolderLevel
SpanFolderSummations SubFolder.Path, FolderLevel
Next SubFolder
Set FileItem = Nothing
Set SourceFolder = Nothing
End Sub