I download a lot of PDFs, jpegs, PNG etc that are only needed for a few hours. Is there a way to make a folder which allows me to access the items but periodically self deletes (sends everything to the trash folder) or tag them in such a way that individual files will delete themselves after a given time limit?


I use hazel to set up rules for a folder. The rules include delete after a time, move to a dated folder.


Here's one that won't cost you any money :) (and not much time, either!). NOTE however, that the solution I've described below will delete these files permanently rather than sending them to the Trash folder.

If you prefer to send files to Trash instead of permanent deletion (using the rm shell command), there are other utilities available to do that. trash is available in Homebrew, and there are others discussed in this thread.

Anyway, following is my recipe to permanently delete these downloaded files:

  1. Create the directory you want to use to hold your "short-term" files & folders:
$ mkdir ~/Desktop/DwnLoads
  1. Create a cron job to periodically delete the contents of the directory you just created:
$ crontab -e

Your crontab will be opened with the default editor. This will likely be vi unless you've changed it. If you don't like vi (I don't), you can use nano instead (v. ez to use). Here's how to open your crontab with nano:

EDITOR=nano crontab -e

Add the following line to the bottom of your crontab:

0 */4 * * * rm -rf ~/Desktop/DwnLoads/*

This particular entry will delete all files and sub-folders in ~/Desktop/DwnLoads (the DwnLoads folder on your Desktop) every 4 hours. If you want something different than 4 hours, that's easy to change. If you're not familiar with the crontab syntax, there's a great website that will take will help you developing the crontab expression you want.

That's it. Let us know if you have questions, and we'll try to help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .