Delete files based on date

  • Thread starter Thread starter Jeff Jones
  • Start date Start date
J

Jeff Jones

Are there any out of the box utilities that will delete
files based on their timestamp for WIN2k? I could do it
with robocopy or xcopy, but do not want to copy any
files. I just want to complete some log cleanup. Thanks
 
This VBScript may work for you.

Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("J:\aaaa")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 30 Then
f1.Delete
End If
Next
Set fso = Nothing
Set f = Nothing
Set fc = Nothing
 
Back
Top