Blog

Downloads folder bursting? Here’s a tip…

By Iain Morris posted on July 27th, 2010

Downloads Folder
I’ve found over the months my Downloads folder starts to fill up with all kinds of junk. Old disk images, versions of documentation, expense reports, you name it. All this stuff just sits in my Downloads folder until I consciously go through and delete the outdated stuff and organize the rest of it. To help myself out, I put a very basic bash script in a cron entry that removes old files from the Downloads directory. That way, I have a certain amount of time to move it out. If I don’t, it probably wasn’t worth keeping.

I made a folder in my home directory called “bin” for all my little utility scripts like this one. Here’s the script, which I’ll call “clean_up”:

#!/bin/bash

downloads=/Users/my_user_name/Downloads

find ${downloads} -mtime +7d -delete

This will remove anything that hasn’t been touched in over a week. That all there is to it! Now put it in your user crontab with crontab -e:

0 * * * * /Users/my_user_name/bin/clean_up

As an example, this will make it run on the hour, every hour. Adjust to something that suits you. But be careful tinkering with find! It can be easy to delete things you meant to keep if you don’t pay attention to the switches.

Posted in Apple, One liners, Scripts, Tips and Tricks

Leave a Reply