I have a script that will recursively output all files, paths and file
properties to an excel spreadsheet. I want to modify it to find and output
only .mdb or ldb files. It is probably simple but i cant figure out where to
put in the logic for the "Where extension = 'adb' or ldb" type of command or
maybe I have to use GetExtensionName method?
Any help to modify the scipt below is appreciated
***********************************************************
' steps recursively through folder and outputs all files, file sizes etc.
Option Explicit
Const cOwner = 12
Dim sFolder
Dim i, sHeadings
Dim objFso, objShell
Dim objExcel, objWorkbook, objWorksheet
sFolder = "\\Server\groups2\BusinessIntelligence\"
sHeadings = Array("File Name", "File Path", "File Size in Bytes" ,_
"Date Created", "Last Accessed", "Last Modified", "Owner")
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\spreadsheet.xls")
Set objWorksheet = objWorkbook.Worksheets(1)
i = 2
With objWorksheet
For i = 0 To UBound(sHeadings)
.Cells(1,i+1).Value = sHeadings(i)
Next
.Range(.Cells(1,1), .Cells(1,i)).Font.Bold = True
End With
List_Files_In_Folder sFolder, 2
'==============================
Sub List_Files_In_Folder(sFolder, row)
Dim objFolder, objFiles, objFile, objSubFolder
Dim objShFolder, objItem
'Get properties of files in folder
Set objFolder = objFso.GetFolder(sFolder)
Set objFiles = objFolder.Files
Set objShFolder = objShell.Namespace(sFolder)
With objWorksheet
.Cells(row,1).Value = objFile.Name
.Cells(row,2).Value = objFile.ParentFolder
.Cells(row,3).Value = objShFolder.GetDetailsOf(objItem,8)
.Cells(row,4).Value = objFile.DateCreated
.Cells(row,5).Value = objFile.DateLastAccessed
.Cells(row,6).Value = objFile.DateLastModified
.Cells(row,7).Value = objShFolder.GetDetailsOf(objItem, cOwner)
End With
row = row + 1
Next
'Process subfolders recursively
For Each objSubFolder In objFolder.SubFolders
List_Files_In_Folder objSubFolder.Path, row
Next
End Sub