Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 4

Delete all files from a folder by create date

I am looking for the best way to delete all files from a folder based on a certain date.  For example I only want to keep files for the past 6 months and anything older I want to delete.  What is the best approach to do this?


Labels (1)
0 Kudos
(1) Reply
Level 6

I don't know what might be best, but here are some thoughts:

If you're so inclined, creating a dll to do this would probably work well. If that's not an option you can do this pretty well with a powershell or vbscript custom action. If you're concerned about possible security blocks you could write something up in InstallScript to do this. To get you started on that you can check-out GetFileInfo, that will get you the date, there's a link to an example on that page. Loop through all the files/folders, checking the date on each, and delete it if it matches the criteria. Here's a link to all the File/Folder functions. I hope some of this helps!

0 Kudos