The functionality of the old Trash folder is something that’s always annoyed me. You either never remember to empty it, and if you do, it’s all or nothing. While playing around with Ubuntu, I noticed this and a lack of a secure delete option. Nor was there any simple way to clear your history of recently opened documents. Missed features like this are fun to script around.

Pretty similar to an OSX script I’ve written to do the roughly the same, Periodic.sh will prune your Trash based on how old it is. Securely deleting it should be a feature of any Trash folder, so that’s in there too (secure-delete toolkit required, apt-get install secure-delete). Clearing your recently opened items is optionally thrown in also, since Ubuntu is missing this as well.

Usage:

Periodic.sh -n [seconds to keep trash] -w [your home directory] -m [maximum entries]  -h [true|false] -s [true|false]

-h = delete history
-s = secure delete, requires srm (secure deletion toolkit)

I don’t have any desktop Linux machines other than Ubuntu, but it’s probably safe to say this wouldn’t work with any other distribution.. at least not without some minor modifications.

Categories: Scripts

2 Comments

Matthäus · January 9, 2013 at 4:10 am

Hey, I did something similar myself, but now I found out that there exist packages like autotrash or trash-cli.
Regards

    JP · January 12, 2013 at 9:10 am

    Will check it out, thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *