I need to report on what files have not been accessed in last 90 days (VBS below) and record the directory and subdirectories and files that fall into this category

Please ignore the move statement.. All i need to do is report on what files have not been accessed in last 90 days and record the directory and subdirectories and files that fall into this category, any ideas would be great....


' Declaration of objects
Dim FSO, f, fld, fls, vSourceDir, vArchiveDir

' Setting data directories
 vSourceDir = "d:\data\"
 vArchiveDir = "d:\Archive\"
 
 'Setting Log file to d:\...."Date script run.txt"
 datelogfile = "d:\ArchiveLog\" & CStr(Replace(FormatDateTime(Now, vbShortDate), "/", "-", 1, -1, 1)) & ".txt"
 
 ' Set obejcts standard VBs
 Set fst = CreateObject("Scripting.FileSystemObject")
 Set flog = fst.CreateTextFile(datelogfile, True)
 Set FSO = CreateObject("scripting.filesystemobject")
 Set fld = FSO.GetFolder(vSourceDir)
 Set fls = fld.Files
 
' Loop for each file in directroy, move from source to archive folder and record moved file to logfile
 For Each f In fls
  If f.DateLastAccessed < DateValue(CStr(Now)) - 90 Then flog.WriteLine (f.shortname)
'  If f.DateLastAccessed < DateValue(CStr(Now)) - 30 Then f.Move vArchiveDir (Commented out)
  Next
 
 'Reset everything to 0 \ Blanks.
 
 Set FSO = Nothing
 Set f = Nothing
 Set fld = Nothing
 Set fls = Nothing
 Set vSourceDir = Nothing
 Set vArchiveDir = Nothing
dutboyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Here's my take on it...

Dim fso, OlderThanDate, logFileName, logFile, startFolder

OlderThanDate = DateAdd("d", -90, Date)
startFolder = "C:\Documents and Settings\Michael\My Documents\1 VB Code\2 VBScript Testing"
logFileName = "c:\" & CStr(Replace(FormatDateTime(Now, vbShortDate), "/", "-", 1, -1, 1)) & ".txt"

Set fso = CreateObject("Scripting.FileSystemObject")
Set logFile = fso.CreateTextFile(logFileName, True)

logFile.WriteLine "Recursive Search Starting In: " & startFolder
logFile.WriteLine "For Files Older Than: " & OlderThanDate
logFile.WriteLine "------------------------------"

SearchForFiles startFolder, OlderThanDate, logFile

Function SearchForFiles(folderName, BeforeDate, logFileStream)
    Dim folder, file, fileCollection, folderCollection, subFolder

    Set folder = fso.GetFolder(folderName)
    Set fileCollection = folder.Files
    For Each file In fileCollection
        If file.DateLastModified < BeforeDate Then
            logFileStream.WriteLine file.Path
            logFileStream.WriteLine file.DateLastModified
            logFileStream.WriteLine "------------------------------"
        End If
    Next

    Set folderCollection = folder.SubFolders
    For Each subFolder In folderCollection
       SearchForFiles subFolder.Path, BeforeDate, logFileStream
    Next
End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.