Merlin’s weekly podcast with Dan Benjamin. We talk about creativity, independence, and making things you love.
Merlin’s weekly podcast with Dan Benjamin. We talk about creativity, independence, and making things you love.
”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)
clofresh | Feb 23 2006
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:
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. 2 Comments
POSTED IN:
About clofresh |
|
EXPLORE 43Folders | THE GOOD STUFF |