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
Posted on 2006-04-04
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)
'Reset everything to 0 \ Blanks.
Set FSO = Nothing
Set f = Nothing
Set fld = Nothing
Set fls = Nothing
Set vSourceDir = Nothing
Set vArchiveDir = Nothing