Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Suppose I want to fill up a flash drive with the most recent photos in my iPhoto Library.

  • I want to end up with an external drive that has all my photos in a single directory (no nested folders)

  • Those photos that have been modified, I want the modified version of the photo to end up on the drive.

  • Those photos that have not been modified, I want the original version of the photo to end up on the drive

  • I want to start with the newest photo and work backward in time, so when the drive fills up, the latest photos will be included on the external drive.

  • I fully expect that the external drive cannot hold all the pictures in my library. Any warning to this effect must be non-modally, and not prevent the script from proceeding to fill the drive with the newest photos in my library, then halt gracefully when the disk is full.

  • I want to do this programmatically (shell or AppleScript), without launching iPhoto.

Does anyone know how to go about doing this? I've written some shell scripts over the years, but none of them quite work the way I'd hoped.

I suspect the right answer will involve some copying and some "if" statements.

share|improve this question
    
While I suspect it's possible to open the iPhoto library bundle and traverse it's directory structure this seems a fragile and error-prone method of "backup". I would assure I had adequate disk space and back up the iPhoto library by making a copy of the iPhoto Library file. –  jaberg Mar 20 '12 at 4:44
    
@jaberg For many steps of my backup, of course that's what I do. Time Machine, etc. But photos are special. I regularly store the most recent n GB of photos on a flash drive off-site. This is in addition to my normal backup routine. If I lose the drafts of my review of Markdown for the AD blog, oh well. If I lose photos of my kids, that's a problem. This is an extra step of backup. –  Daniel Lawson Mar 20 '12 at 4:48
    
Point taken. My digital photos were the motivation behind my developing my own backup strategy—SuperDuper! and Crashplan Central. That being said, it's the very importance of those files that causes me to question an "unsupported" script-based backup system. There is no easy way to sort out the exact files you want, and the complexity of the system is what makes it delicate. –  jaberg Mar 20 '12 at 4:56
    
I'd suggest you get Amazon S3 and Arq (haystacksoftware.com/arq) and backup all your photos ;) –  Martín Marconcini Mar 20 '12 at 7:58
    
Shouldn't this be on Stack Overflow? wink wink –  bmike Mar 30 '12 at 17:18

1 Answer 1

up vote 5 down vote accepted
+100

I have written a script to do this for you. It is available here. It works with system Ruby (1.8.6 in Lion) with no external dependencies. This is how you use it (also included in the README):

This script looks for an iPhoto '11 album data file in

~/Pictures/iPhoto Library/AlbumData.xml

This is the standard place for iPhoto to store the album data file, so it's very likely you have it here if you have iPhoto.

Recommended use for the script is to copy it to wherever you wish to backup the files to, then invoke it on the command line:

$ruby iphoto.rb

This will scan the album data file, sort the photos by date, newest first, then copy them to the desired destination until the drive is full. Alternatively, you can manually specify the path you wish to copy to as an argument parameter, in case you want to store the script somewhere else:

$ruby iphoto.rb /Volumes/Backup

This script was written with exactly one user in mind; that is why it has no other options.


  • I have tested this on exactly one iPhoto library: mine. It works for me, but YMMV.
  • The number in front of the files is the "DateAsTimerInterval" value from the album data file. I don't know how to convert it to a "real" date, but sorting by it does sort chronologically, so it's good enough for the purposes of this script.
share|improve this answer
    
P.S. Please no comments on coding style or whatever, this was one of those projects where I stopped once it worked. And yes, it does use a regex to parse XML - again, it works, and I didn't find a built-in XML lib I liked (I didn't want to add dependencies) –  Kyle Cronin Mar 30 '12 at 1:30
    
If a picture was modified your script will also copy the original - right ? –  iolsmit Mar 30 '12 at 1:49
    
@iolsmit As per Daniel's specs, the script will not copy the original if it was modified –  Kyle Cronin Mar 30 '12 at 1:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.