Hi everyone,
I have written a script that will help me export all of my photos from iPhoto, multiple albums at a time. I’ve already written the parts that allow the user to select the album(s) to export, and to select that album and iterate through all photos in the album. I’m stuck on the very last line of the script where I’m attempting to copy the photo image to a target folder.
The culprit appears to be this line. I’ve tried many variations:
tell application "Finder" to duplicate POSIX file source_Image_Path to export_Folder & ":" & (a_Photo's name) & ".jpg"
The error I receive is as follows:
error "Finder got an error: Can't set \"Macintosh HD:Users:eh:Desktop:iPhoto Export:2009-09-28 Dumbarton Bridge:IMG_1656.JPG.jpg\" to POSIX file \"/Users/eh/Pictures/iPhoto Library/Originals/2009/Dumbarton Bridge/IMG_1656.JPG\"." number -10006 from "Macintosh HD:Users:eh:Desktop:iPhoto Export:2009-09-28 Dumbarton Bridge:IMG_1656.JPG.jpg"
The challenge seems to be that the way I’ve defined “export_Folder” and the way that the iPhoto Album’s Photos collection handle paths are different, and I don’t know how to make them the same so that the Finder’s “duplicate” command doesn’t gag on the inputs.
Here is how I have defined export_Folder:
set export_Folder to "Macintosh HD:Users:eh:Desktop:iPhoto Export:" & selected_Album
Any help with this path issue would be a great help, thanks in advance!
For reference, here is the entire script. If you want to run it on your own system, you’ll have to change the hard-coded path to the Desktop where export_Folder is defined, and you’ll have to have at least one Album in iPhoto.
Export Albums v0.01 - Eric Heitzman
tell application "iPhoto"
-- For convenience, you can hardcode the name of some iPhoto albums (useful during development)
-- set iPhoto_All_Albums_List to every album
-- set selected_Albums to {"2009-10-19 Australia Sydney Bondi, Cape Tribulation", "2009-10-17 Snorkeling Cape Tribulation"}
set iPhoto_All_Albums_List to every album
set iPhoto_All_Album_Names_List to {}
-- Create a variable called iPhoto_All_Albums_List containing the names of all albums with type "regular album"
repeat with iPhoto_Album in the iPhoto_All_Albums_List
if ((iPhoto_Album's type as text) contains "regular album") then
set end of iPhoto_All_Album_Names_List to iPhoto_Album's name
end if
end repeat
-- Allow the user to select with of the "regular album" entries to export
set selected_Albums to choose from list iPhoto_All_Album_Names_List with title "iPhoto Album Exporter" with prompt "Select which album(s) you want to export." with multiple selections allowed
-- debug output: display the names of the selected output (all run together)
-- display dialog "You selected: " & selected_Albums
repeat with selected_Album in the selected_Albums
repeat with iPhoto_Album in the iPhoto_All_Albums_List
if ((iPhoto_Album's name) contains (selected_Album as text)) then
-- debug output: display the name each selected album
-- display dialog (iPhoto_Album's name as text) giving up after 1
-- Create a new folder for each Album to be exported. This works as long as there isn't a collision.
tell application "Finder" to make new folder at alias "Macintosh HD:Users:eh:Desktop:iPhoto Export:" with properties {name:selected_Album}
set export_Folder to "Macintosh HD:Users:eh:Desktop:iPhoto Export:" & selected_Album
-- Duplicate each photo file in the iPhoto_Album to the export_Folder
set all_Photos_List to photos of iPhoto_Album
repeat with a_Photo in the all_Photos_List
-- debug output: display the name and path of each photo in the album
-- display dialog (a_Photo's image path as text) giving up after 1
set source_Image_Path to (a_Photo's image path)
tell application "Finder" to duplicate POSIX file source_Image_Path to export_Folder & ":" & (a_Photo's name) & ".jpg"
end repeat
end if
end repeat
end repeat
end tell