Automatically import (and tag) Photo Booth photos into iPhoto

Written . Tagged AppleScript, OS X.

When you take pictures with Apple’s Photo Booth, there is a button to import them into iPhoto one at the time.

Having decided yet again to try to get used to the metadataness of OS X, this annoys me. If iPhoto is supposed to handle my images, abstracting away the file system, I want new photos to go there automatically.

I created a folder action that does just that. Assuming you enable Folder Actions and attach this one to the Photo Booth directory (instructions), new photos will automatically be imported into iPhoto and tagged with “Photo Booth”.

The script assumes that you have created a “Photo Booth” tag in the iPhoto settings, and a smart album named “Photo Booth” that displays the photos with that tag.

Script (download, recommended location /Library/Scripts/Folder Action Scripts/):

1
2
3
4
5
6
7
8
9
on adding folder items to this_folder after receiving added_items
  tell application "iPhoto"
    import from added_items
    delay 5 -- wait for import to finish
    tell (the first album whose name is "Last roll") to select photos
    assign keyword string "Photo Booth"
    select (the first album whose name is "Photo Booth")
  end tell
end adding folder items to

The delay is in seconds. If the import doesn’t finish before the script tags whatever is in “Last roll”, increase the delay. This seems to work fine for me.

After assigning the tag, the “Photo Booth” album is selected, i.e. its contents are displayed.

Optionally, if you want to stick Photo Booth photos into a regular (non-smart) folder and not tag it, try something like this instead:

1
2
3
4
5
6
on adding folder items to this_folder after receiving added_items
  tell application "iPhoto"
    import from added_items to (the first album whose name is "Photo Booth")
    select (the first album whose name is "Photo Booth")
  end tell
end adding folder items to

This solution is not perfect – I would ideally want the script to delete the original images, only keeping them in iPhoto, but still have them display in the Photo Booth history. This is probably possible by modifying the Recents.plist file, which I have not yet had time to look into.

Throw in a quit on its own line before end tell to quit iPhoto when done. I prefer to leave it open since I will usually take more photos, and also so that I can add further tags.