I found a script on the net that searches a folder for the names of
subfolders and files and pumps that information to a log file. I have
modified the script to gather more info and to export the data to an Excel
spreadsheet. I just wanted to get some feedback on it. Thanks, Jeremy
-----------------------------------------------------------------------
'Purpose of this script is to recursively search a directory
'to return the following info about subfolders and subfiles
'Date Created, Date Last Accessed, Date Last Modified,
'Name, Path, Size and Type.
'And to massage that all into an Excel spread sheet
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 2
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
'LogFile = "f:\jeremy-data\documents\exportme.log"
'Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Date Created"
objExcel.Cells(1, 2).Value = "Date Last Accessed"
objExcel.Cells(1, 3).Value = "Date Last Modified"
objExcel.Cells(1, 4).Value = "Name"
objExcel.Cells(1, 5).Value = "Path"
objExcel.Cells(1, 6).Value = "Size"
objExcel.Cells(1, 7).Value = "Type"
objStartFolder = "f:\jeremy-data\documents\"
Set objFolder = objFSO.GetFolder(objStartFolder)
'objLogFile.Write objFolder.Path
'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFolder.DateCreated
objExcel.Cells(intRow, 2).Value = objFolder.DateLastAccessed
objExcel.Cells(intRow, 3).Value = objFolder.DateLastModified
objExcel.Cells(intRow, 4).Value = objFolder.Name
objExcel.Cells(intRow, 5).Value = objFolder.Path
objExcel.Cells(intRow, 7).Value = objFolder.Type
intRow = intRow + 1
Set colFiles = objFolder.Files
For Each objFile in colFiles
' objLogFile.Write objFile.Name
'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFile.DateCreated
objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed
objExcel.Cells(intRow, 3).Value = objFile.DateLastModified
objExcel.Cells(intRow, 4).Value = objFile.Name
objExcel.Cells(intRow, 5).Value = objFile.Path
objExcel.Cells(intRow, 6).Value = objFolder.Size
objExcel.Cells(intRow, 7).Value = objFile.Type
intRow = intRow + 1
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
'objLogFile.Write Subfolder.Path
'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = subFolder.DateCreated
objExcel.Cells(intRow, 2).Value = subFolder.DateLastAccessed
objExcel.Cells(intRow, 3).Value = subFolder.DateLastModified
objExcel.Cells(intRow, 4).Value = subFolder.Name
objExcel.Cells(intRow, 5).Value = subFolder.Path
objExcel.Cells(intRow, 6).Value = objFolder.Size
objExcel.Cells(intRow, 7).Value = subFolder.Type
intRow = intRow + 1
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
'objLogFile.Write objFile.Name
'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFile.DateCreated
objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed
objExcel.Cells(intRow, 3).Value = objFile.DateLastModified
objExcel.Cells(intRow, 4).Value = objFile.Name
objExcel.Cells(intRow, 5).Value = objFile.Path
objExcel.Cells(intRow, 6).Value = objFolder.Size
objExcel.Cells(intRow, 7).Value = objFile.Type
intRow = intRow + 1
Next
ShowSubFolders Subfolder
Next
End Sub
objLogFile.Close
wscript.echo "Done!"