- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Delete all files from a folder by create date
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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!