Automatic File Deletion

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Can I set up a task to autmatically delete files created
at least 10 days ago?
 
This VBScript may work for you.

Dim fso, f, f1, fc, s
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Can't delete file 3
automatic calculation 3
Outlook Auto-Email 1
File Inheretance 3
Best tool to recover PST files in 2026 0
PDF Files 3
How do I set up a footer file name to update autmatically 1
strange behavior 4

Back
Top