tags:

views:

187

answers:

2

I want to make a script that automatically backs up my kindle files when I connect it to my macbook pro. Writing the script is well within my ability, but I don't know what's the best way to run a script on mount automatically.

A: 

What kind of scripting did you have in mind? If you are using AppleScript, would it be possible to attach a folder action to the /Volumes directory (or maybe the specific subdirectory on which the Kindle mounts) to back up the files? I've never tried something like that, so use the idea at your own risk, but for what it's worth...

Other than that, I don't know of a general way to run a script on a mount in OS X. Kevent, which is OS X's version of Linux's inotify, would be a way something like that might be accomplished, but obviously you don't want to write a C program for all of this. One might be out there though.

Tim Yates
+4  A: 

You could either use AppleScript and attach a folder action to the /Volumes directory, or you could write a Launch Agent that watches that path.

For the latter, you can refer to Tutorial: Backups with Launchd on MacResearch. The gist of it is that you create a plist configuration file to be interpreted by launchd; then launchd will execute your script when the specified path has changed.

benzado