Option Explicit
on error resume Next
Dim obj_FSO
Dim char_Dir
Dim obj_Folder
Dim obj_FileColl
Dim obj_File
Dim obj_ArcFile1
Dim int_DaysOld
Dim char_date
int_DaysOld = 7 'age in days
char_Dir = "C:\yourdir\here" 'target dir
char_date = Year(Now) & Right("0" & Month(Now),2) & Right("0" & Day(Now),2)
Set obj_FSO = CreateObject("Scripting.FileSystemObject")
Set obj_Folder = obj_FSO.GetFolder(char_Dir)
Set obj_FileColl = obj_Folder.Files
Set obj_ArcFile1 = obj_FSO.CreateTextFile("c:\yourdir\logdir\DelFile1_" & char_date & ".txt", True)
'DateLastModified is what is shown via explorer in windose
'can also use DateCreated and DateLastAccessed based upon needs
For each obj_File in obj_FileColl
If DateDiff("d", obj_File.DateLastModified,Now ()) > int_DaysOld Then
obj_ArcFile1.WriteLine(obj_File & " " & obj_File.DateLastModified & " Deleted")
obj_File.Delete(True)
End If
Next
obj_ArcFile1.Close
'clear objects
Set obj_FSO = Nothing
Set obj_Folder = Nothing
Set obj_FileColl = Nothing
Set obj_File = Nothing
Set obj_ArcFile1 = Nothing