Trash Downloads After 7 Days (Directory Automation)

I use this macro to automatically trash downloaded files older than 7 days every hour. The reason for the hour part is because I use a laptop which is obviously not 24/7 on.
The directory, wait duration and action on the file can easily be changed.

The macro is disabled in Test Group

Screenshot:

Macro:
Trash downloads after 7 days.kmmacros (6.5 KB)

2 Likes

While I admire the work on this macro I have taken a different approach. Using the Mac's native Automator app I was able to create this process with four simple steps:

  1. Get Specified Finder Item (navigate to the folder that you want to scan - you can repeat this step with multiple folders).
  2. Get Folder Contents.
  3. Filter Finder Names (using the Date Created option).
  4. Move Finder Items to Trash.

I added a notification step at the end (Display Notification) so that I'd get an alert when it runs. I then just set up a timed trigger (you can set up multiple triggers if you prefer) and use the "Execute" Action Item.

My logic is that the native app Automator is more reliable, runs faster and is just easier to build. Using KM to trigger it is better than making it a Calendar Item, which I have always found to be unreliable.

Just my 2 cents.

Sounds sensible! This came to be as a learning exercise in date manipulation.

Agreed - I completely get that. I have found that date manipulation, whether using KM, AppleScript or Terminal commands, to be one of the least understandable factors in scripting.

Good luck in your continued pursuit of a clean drive. If you need any assistance using Automator for this task let’s continue the discussion. As noted earlier, I recommend against using Automator’s built-in Calendar event function for triggers; KM’s is much more robust and reliable.

1 Like