Auto delete Dropbox public files after 2 weeks in OS X

This little shell script will run once a day to delete any files that were created over 2 weeks ago using crontab and find.

Installing

Just fire up Terminal, and type crontab -e then paste in the following on a new line:

 00 16 * * * find ~/Dropbox/Public -mindepth 1 -ctime +14 -delete

You can of course adjust the path to whatever it is on your system.

Write and save that and you’ll get a message saying crontab: installing new crontab. Now at 16:00 every day, any file that was created (includes copied) in the folder more than 2 weeks ago will be deleted.

Uninstalling

If you need to delete the cron job, just run crontab -e again and remove the line.