Cacomania: Auto cleaning up your download folder with find

Cacomania

Auto cleaning up your download folder with find

Guido Krömer - 15. August 2012 - Tags: ,

Is your download folder messy, too? Why not let find tidy it up periodically?

# find ~/Downloads/* -ctime +7 -exec rm -rf {} \;

The command above let find search for files and folder which are older than 7 days and deletes them. But be carefully files in a folder will be deleted even if the file age is newer than 7 days if the folder is older than 7 days!

0 * * * * find ~/Downloads/* -ctime +7 -exec rm -rf {} \; > ~/Downloads/deleted.files

Running this as a cronjob will do the work once a hour, or how often you wants.