'========================================================= ' ' DESC: Automatically generates an Excel listing of ' all files in a local directory, along with their file ' attributes. ' ' USAGE: Place files.vbs in the directory you wish ' to list and double click it. Does not list subfolders ' or itself. ' ' AUTHOR: Todd Woolums (twoolums@toddwoolums.com) ' DATE : 05/29/2004 ' VERSION: 1.0 '========================================================= Dim objXL Dim fso Dim f Dim fl Dim fc Dim scriptfile Dim scriptpath Dim count Welcome_MsgBox_Message = "This application lists all " & _ "files in a directory in an Excel workbook." Welcome_MsgBox_Title = "File Lister" Call Welcome() scriptfile = WScript.ScriptFullName Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(scriptfile) scriptpath = f.ParentFolder Set f = Nothing Set objXL = WScript.CreateObject("Excel.Application") objXL.Visible = TRUE Set fl = fso.GetFolder(scriptpath) Set fc = fl.Files objXL.Workbooks.Add objXL.Cells(1,1).Value = "Folder:" objXL.Cells(1,2).Value = scriptpath objXL.Cells(2,1).Value = "Filename" objXL.Cells(2,2).Value = "Type" objXL.Cells(2,3).Value = "Size (bytes)" objXL.Cells(2,4).Value = "Date Created" objXL.Cells(2,5).Value = "Date Last Modified" objXL.Cells(2,6).Value = "Date Last Accessed" count = 3 For Each f in fc If f.name <> "files.vbs" Then objXL.Cells(count,1).Value = f.name objXL.Cells(count,2).Value = f.type objXL.Cells(count,3).Value = f.size objXL.Cells(count,4).Value = f.DateCreated objXL.Cells(count,5).Value = f.DateLastModified objXL.Cells(count,6).Value = f.DateLastAccessed count = count + 1 End If Next ' Cleanup Set fc = Nothing Set fl = Nothing Set fso = Nothing Set objXL = Nothing WScript.Quit Sub Welcome() Dim intDoIt intDoIt = MsgBox(Welcome_MsgBox_Message, _ vbOKCancel + vbInformation, _ Welcome_MsgBox_Title ) If intDoIt = vbCancel Then WScript.Quit End If End Sub