Simple way to keep your download folder tidy

From Danny O'Brien, a nice hack for keeping your download folder tidy -- a script that deletes everything that's more than a week old. I'd like one of these to run on my ~/.Trash folder, too.
I've had bad experience with handing "delete file" powers to an automatic script before, so I'll disclaim any warranty ("TO THE EXTENT PERMITTED BY APPLICABLE LAW" as the GPL shouts), but it's pretty straightforward, and works for me: I have it in a cronjob. The tmp folder it cleans up is my default save folder on Firefox, and where I generally download everything. If I want to save anything longer than a week, I find it a place in the rest of my filing system. It's sort of like having a cleaner come around every week: occasionally you go "Garr! Where's that coffee-stained, have torn copy of last month's New Yorker! I was going to eventually get around to reading that!", but mostly your cruft just silently disappears without you noticing a thing.
the most useful simple script i have


  1. I keep my Desktop free of icons. Everything I download goes onto my Desktop. When you can’t find anything because the thing looks so cluttered you tend to organise (i.e. move for permanent storage or delete) it pretty quick.

  2. #2 — because you probably want atime, not mtime. Or at least I do. Except for directories, where atime is useless. Since tmpwatch comes with all Red Hat-family distros (and probably most other Linux flavors as well), I typically do this in my crontab:

    /usr/sbin/tmpwatch –dirmtime 240 ~/tmp

  3. I’ve been playing with AWN’s “Stacks” applet, which combined with the ‘folder’ backend, sorted by date and set to the “Trasher gui” layout, -might- just replace my current system of, yes, dump everything on ~/Desktop and tidy up when it reaches to my second monitor.

    I’d love a way to automatically identify, collate, and file images which are also cat macros though. I wonder if I could OCR them… *wanders off absentmindedly*

  4. I use the Mac program Hazel for this:
    It lets you set up arbitrary rules for processing items in folders, either at the point they get added or at any later time. Very useful for a variety of things, and very intuitive to use.

    (Yes, I know shell scripting, but I don’t want to have to put on my programmer’s hat and waste ten minutes getting stupid quotes in the right places, when all I wanted to do was clean up my downloads.)

  5. The function this describes seems much too simple for a script. Just save

    @weekly rm -r {your temp folder}

    to a text file, then run

    crontab {the filename}

    in a terminal. You’re done. You don’t get any confirmation stage, but if you want to see what the job would delete, you could also just open the temp folder in your file manager.

  6. …Except that this will actually delete *everything* in the folder, not just unmodified-in-a-week stuff. Sorry, I misunderstood what the script claimed to do.

  7. Huh? Just buy a bigger disk. By the time your drive is full, it’s time to upgrade. The old one’s probably worn out anyway.

  8. Mac users can use rmtrash, available from Mac Ports. Instead of deleting of files, it moves them to the trash folder.

    Danny’s script seems a bit like overkill, though.


  9. #2 — your script was similar to my script, until it hit files with spaces in their name

    tmpwatch and tmpreaper are both perfect for this job, too.

Comments are closed.