Applescript for iPhoto

I was helping Anna pull some pictures off of our new camera so she could export them at a smaller size, and post them to her etsy shop:
So of course being the kind of guy that I am I decided to script the entire process, and ended up with a drop dead simple solution that only requires you to connect the camera to a USB port and press Yes/No on a single dialog box. It automatically launches when the camera is connected thanks to the setting being an option on Image Capture to launch any random script. Then it imports your photos into iPhoto (which is nice enough to recognize duplicates and ask what you want to do with them), then it asks if you want to export or not, and if you answer yes exports the photos to the dedicated Etsy directory on Anna’s desktop. Once that is complete it automatically unmounts the camera storage card so you can just pull the USB cable and get on with your life. I call it

— First we do the importing
tell application “iPhoto”
import from “/Volumes/DMC-FZ28/DCIM/101_PANA”
end tell
delay 3
— Then we do the exporting
property maxPixel : 800
property destinationFolder : “/Users/jayholler/Desktop/Etsy/” — the trailing slash is required

tell application “iPhoto”
select photos of album “Last Import”
set sel to selection
end tell
display dialog “Do you want to export these photos to Etsy?” buttons {“No”, “Yes”} cancel button 1 with title “Jay’s Awesome iPhoto Script” with icon stop
if result = {button returned:”Yes”} then
repeat with onePhoto in sel
tell application “iPhoto” to set {pLocation, pName} to {image path, title} of onePhoto
do shell script “sips -Z 800 -i -s format jpeg -s formatOptions best ” & quoted form of pLocation & ” –out ” & quoted form of (destinationFolder & pName & “.jpg”)
end repeat
end if

do shell script “hdiutil unmount /Volumes/DMC-FZ28″

if result = {button returned:”No”} then
do shell script “hdiutil unmount /Volumes/DMC-FZ28”
end if

This is how the dialog looks:


Author: jayholler

A technology lover living in California with my wife and two children.

One thought on “Applescript for iPhoto”

  1. This seems like exactly what I’m looking for. Too bad I have no idea what you’re saying to do! I’m a bit of a techno-peasant.
    I don’t know what you mean when you say “tell” application iPhoto…and “tell delay 3” (what’s delay 3?) etc. Also, is this all something you need to do every time you take a batch of photos you want to upload to Etsy, or is it something you do once and then can just select as an option like an automatic popup that asks you if you want to export to Etsy automatically?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s