Jay Holler’s Blog

Icon

A technologist living in Philadelphia

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: http://www.etsy.com/shop/mamaholler
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 iPhoto_Magic.app:

– 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:

Filed under: Uncategorized

Leave a Reply

Latest Tweets

  • Thanks in part to @jackmorales and in part to the excellent work being done in Banshee for Linux, I think I may be finally purging Apple. 1 day ago
  • All I have to say is I love the writers for Lost. Great material, even if all their ideas are recycled from science fiction novels. 6 days ago
  • Cannot believe that the final season of Lost is upon us. We've been watching the previous seasons in anticipation. Great show. 6 days ago
  • OK, so you're telling me that the iPad is essentially a giant iPod Touch?! No multitasking, no Flash, no non-App Store 3rd party apps?!?!?! 1 week ago
  • Back to work tomorrow for the first time in 2010. I wish that I was off on vacation that whole time or something. Working at home for now. 2 weeks ago