43 Folders

Back to Work

Merlin’s weekly podcast with Dan Benjamin. We talk about creativity, independence, and making things you love.

Join us via RSS, iTunes, or at 5by5.tv.

”What’s 43 Folders?”
43Folders.com is Merlin Mann’s website about finding the time and attention to do your best creative work.

Organize downloads in folders named by date (or, finally a practical use for launchd)

So I wanted a way to organize my downloads folder by date, kind of like how Shiira does it, but will work with any file I through in there. So I wrote this bash script called organize_downloads:

#!/bin/bash

current=`current_workspace`
if ! [ -d $current ]
then
mkdir $current
fi
mv $HOME/Downloads/* $current

Where current_workspace is another bash script:

date +$HOME/Desktop/Workspaces/%m-%d-%y

I put these two scripts in ~/bin, which is in my path, and gave them the proper permissions. So now when I run organize_downloads, it moves everything in ~/Downloads to a folder of the form ~/Desktop/Workspaces/MM-DD-YY where MM-DD-YY is the current date.

To get organize_downloads to run every time a file hits ~/Downloads, I created a Launchd item:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.clofresh.organizeDownloadsByDate</string>
        <key>Program</key>
        <string>/Users/carlo/bin/organize_downloads</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Users/carlo/bin/organize_downloads</string>
        </array>
        <key>ServiceDescription</key>
        <string>moves anything that is created in ~/Downloads to ~/Desktop/Workspaces/MM-DD-YY where MM-DD-YY is the current date</string>
        <key>WatchPaths</key>
        <array>
                <string>/Users/carlo/Downloads</string>
        </array>
</dict>

(I had to use the absolute path to my home directory because apparently ~/ doesn't work)

So I saved that plist as ~/Library/LaunchAgents/com.clofresh.organizeDownloadsByDate.plist and then ran launchctl load Library/LaunchAgents/com.clofresh.organizeDownloadsByDate.plist

And now I have a Workspaces folder on my desktop that organizes by date all my downloads and whatever I wanna throw in there!

The one problem I ran into so far is that I won't get prompted for overwriting a file. Maybe if I use mv -i and then somehow pipe the output into an Applescript alert? I'm not too familiar with Applescript, so someone help me out here.

TOPICS: Mac OS X
mcwitt's picture

Try SafariStand instead

Hello,

my first post on the board, simply because I couldn't stand by as someone worked hard to do a thing which already exists. Go to MacUpdate, find SafariStand, download and install, and be sure to click on the option "Tidy by Date for File Downloads" on the general Settings page. SafariStand does MUCH more than just that, it's a wonderful addition to Safari that pulls together a lot of what other utilities can do into a single package. You can even reorder the tabs by dragging the thumbnails in your new sidebar...

enjoy,
mc

 
EXPLORE 43Folders THE GOOD STUFF

Popular
Today

Popular
Classics

An Oblique Strategy:
Honor thy error as a hidden intention


STAY IN THE LOOP:

Subscribe with Google Reader

Subscribe on Netvibes

Add to Technorati Favorites

Subscribe on Pageflakes

Add RSS feed

The Podcast Feed

Cranking

Merlin used to crank. He’s not cranking any more.

This is an essay about family, priorities, and Shakey’s Pizza, and it’s probably the best thing he’s written. »

Scared Shitless

Merlin’s scared. You’re scared. Everybody is scared.

This is the video of Merlin’s keynote at Webstock 2011. The one where he cried. You should watch it. »