– This is a Folder Actions AppleScript that triggers an
– event when a disk (like an iPod) is mounted by the
– System. I use it to run a compiled Automator workflow that
– backs-up my Keychains, and copies my GTD lists to the
– iPod notes folder.
–
– To run it you should tweak the script accordingly, and add it
– as a Folder Action to the “/Volumes” folder. It isn’t
– exactly obvious how to do this, so here’s how:
–
– 1. Open the “Folder Actions Setup” app.
– 2. Click the ‘+’ button to add a new Folder Action.
– 3. The “/Volumes” directory is hidden from view. Don’t click
– anything, type “/Volumes” to get to it.
– 4. Add this script as a Folder Action.
on adding folder items to thisFolder after receiving addedItems
set volumeName to “Tim Brayshaw’s iPod” – change this!
repeat with addedItem in addedItems
if the displayed name of (info for addedItem) ¬
is equal to volumeName then
volumeMounted()
exit repeat
end if
end repeat
– System Events seems to keep file references open to each of
— the “addedItems” above, this means you can’t eject these
— volumes. This bodge quits System Events, so you can eject
— the added volumes. (System Events gets launched immediately
— again.)
quit application “System Events”
end adding folder items to
on volumeMounted()
tell application “Finder”
open application “Update iPod”
end tell
end volumeMounted
This should world for other devices like USB thumbdrives, external FireWire disks, Digital Cameras etc. I futzed around trying to figure out how to do this with launchd, but gave up. If anyone knows a better or other way, post a comment!
I’ve found this useful because it’s removed some backup anxieties, and means I’ve always got my shopping and out-and-about errands lists (and so on) with me when I’m away for the computer. There’s probably a better way of doing this, but it took me an inordinate amount of time to figure it out, so I thought I’d post a code snippet here for like-minded dabblers.
Published at 1:08 am on July 3rd, 2005.
Topics: GTD Mac Software
7 Comments
Hi Tim,
That’s timely, as I’ve just taken delivery of my first iPod (yay!). Does your script require Tiger, or will it run under Panther?
Comment by Tim Beadle at 3:31 pm on July 11th, 2005 #link
I’ve only tried it with Tiger, although it should work with Panther too.
Be warned, though: I’ve had problems ejecting disks after the computer has slept, then woken. (Although manually quiting the “System Events” process using the Activity Monitor app seems to allow you to eject the disks again). Definitely not ideal, but almost good enough!
Comment by Tim at 12:06 pm on July 12th, 2005 #link
Double warning!(!) I’ve stopped using this while I figure-out the ejecting problem. Tips welcome.
Comment by Tim at 12:35 am on August 25th, 2005 #link
[…] After reading his post How to run a script to do useful stuff when you plug-in your iPod, I was able to adapt this to use the “export to iPod” feature of VoodooPad […]
Comment by Televisionmind » Blog Archive » GTDVoodooPod at 8:39 pm on October 5th, 2005 #link
Ok do you have any more descriptive instructions on how to use this? because I am not experienced using scripts but it sounds like an awesome idea
Comment by matthew morriss at 10:23 pm on November 9th, 2005 #link
you suck tim
you dont know anything
you are such a fuckin loser
Comment by tim sucks at 3:33 pm on November 11th, 2005 #link
Hey ‘tim sucks’ — you fuckin rock! I KISS YOU!
Comment by Tim at 1:16 am on November 12th, 2005 #link