Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Needed: Script for exporting iPhoto albums into a file structure

Hello all! I have no experience with AppleScript, but I heard it should be possible to write a script which helps to copy/export a iPhoto album structure into an according directory structure. Does anybody already have such a script?
Thx for any information on that!

iMac g5 20 2GB, Mac OS X (10.4.5)

Posted on Apr 28, 2006 2:11 PM

Reply
19 replies

May 13, 2006 8:47 AM in response to Thomas Halenbeck

Thomas,

Do you have iPhoto open before you start the script?

Although the script will start iPhoto it often does not wait for it to fully open before it starts trying to run the rest of the commands. With the GUI method I have provided it is critical that iPhoto is fully open and the currently active application for it to work properly.

I have tried to do my best to avoid timing problems but it would also be best if you only had iPhoto running at the time you use the script i.e., quit all other applications.

May 14, 2006 9:07 AM in response to lc55

Hi Ic55,
I have closed all other programms (even Safari), and opened iPhoto before I started the script - same error. This time I did not even reached a file browsing dialog box as I former did. This error occured after a short run time:
--->
tell application "System Events"
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1 of process "iPhoto"
"System Events got an error: NSReceiverEvaluationScriptError: 4"
<---
I have tried to research myself on that error message, but as I do not know much about AS, I did not understand a bit of the comments I read :-(
Anything else I can do?
If you feel so, please dont hesitate to stop working on that project - I dont wanna steal all your time for that!
1000 Thx and greatings from Germany<br>
iMac g5 20 2GB Mac OS X (10.4.5)

May 15, 2006 6:56 PM in response to Thomas Halenbeck

Thomas,

Remember I enjoy puzzles and although, it might seem like I am spending all my time at the computer, I was able to get out and enjoy the beautiful spring weather this last weekend. Hope you were able to do the same.

That AppleScript error means that the AppleScript is trying to interact with a GUI element that it cannot see.

That is why I previously had you make sure the GUI scripting dictionary was being loaded i.e., "Enable access for assistive devices", and make sure that the user interface is responding at a speed that keeps up with the AppleScript i.e., eliminate CPU loading from other applications. As you know neither of these were the problem or the only problem.

Your recent reply made me go back and look more closely at the actual design of the program and redesign a few areas that I am hoping will now make it finally run without errors and more reliably on various machines.

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">property StandardiPhotoAlbums : {"Library", "Last Roll", "Last 12 Months", "Trash"}
property DesktopAlbum : "iPhoto Albums"

tell application "Finder"
-- create a folder on the Desktop to hold the Album file structure
make new folder at desktop with properties {name:DesktopAlbum}
end tell

tell application "iPhoto"

activate
repeat until application "iPhoto" is frontmost
end repeat

repeat with anAlbum in albums -- go through all the albums in iPhoto one at a time

select (name of anAlbum) -- select the next album in iPhoto
set SelectedAlbum to ""
repeat until the SelectedAlbum is equal to (name of anAlbum)
get selection
set SelectedAlbum to name of item 1 of the result
end repeat

if (name of anAlbum) is not in StandardiPhotoAlbums then -- check to see whether it is one of my albums or the iPhoto standards

tell application "System Events"
tell process "iPhoto"
-- Start the Exporting process
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1
repeat until window "Export Photos" exists
end repeat
-- Move to File Export Panel and assume export defaults
click radio button "File Export" of tab group 1 of window "Export Photos"
repeat until value of radio button "File Export" of tab group 1 of window "Export Photos" is 1
end repeat
click button "Export" of list 1 of window "Export Photos"
repeat until sheet 1 of window "Export Photos" exists
end repeat
-- Move to the the Desktop
click button "Desktop" of list 1 of scroll area 1 of splitter group 1 of group 1 of sheet 1 of window "Export Photos"
repeat until value of pop up button 1 of group 1 of sheet 1 of window "Export Photos" is "Desktop"
end repeat
-- Create a new folder on the Desktop with the same name as in iPhoto
click button "New Folder" of sheet 1 of window "Export Photos"
repeat until window "New Folder" exists
end repeat
set value of text field 1 of window "New Folder" to (name of anAlbum)
click button "Create" of window "New Folder"
repeat until ((exists of window "New Folder") is false)
end repeat
-- Start Exporting photos to the new subfolder and wait for all the dialogs to close
click button "OK" of sheet 1 of window "Export Photos"
repeat until ((exists of sheet 1 of window "Export Photos") is false)
end repeat
repeat until ((exists of window "Export Photos") is false)
end repeat
end tell -- iPhoto
end tell -- System Events

-- Move the newly created folder from the Desktop to the originally created folder on Desktop
tell application "Finder"
move folder (name of anAlbum) of desktop to folder DesktopAlbum of desktop
end tell

end if

end repeat

display dialog "All finished exporting your albums from iPhoto..."

end tell



</pre>


PowerBook 12" Mac OS X (10.4.6)

May 16, 2006 11:36 AM in response to lc55

Hi Ic55, thx again for your efforts. Unfortunatly it failed again. Here is the entire EventLog:
--------------- snip ---------------------->
tell application "Finder"
make new folder at desktop with properties {name:"iPhoto Albums"}
folder "iPhoto Albums" of folder "Desktop" of folder "thomas" of folder "Users" of startup disk
end tell
tell application "iPhoto"
activate
frontmost = true
get frontmost
true
count every album
204
select name of item 1 of every album
"Fotoarchiv"
get name of item 1 of every album
"Fotoarchiv"
get selection
{album id 4.295966296E+9}
get name of album id 4.295966296E+9
"Fotoarchiv"
get name of item 1 of every album
"Fotoarchiv"
get name of item 1 of every album
"Fotoarchiv"
end tell
tell application "System Events"
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1 of process "iPhoto"
"„System Events“ hat einen Fehler erhalten: NSReceiverEvaluationScriptError: 4"
<-------------- snap-----------------------

Do you have any suggestion how we can make problem tracking more efficient? Would it be helpful, if we communicate via email and just populate this thread with a result? In case you confirm: halenbeck@mac.com.
Would it be helpful, if you send me a test iPhoto library where you may better can track what happened?
Best regards, Thomas<br>
iMac g5 20 2GB Mac OS X (10.4.5)

Needed: Script for exporting iPhoto albums into a file structure

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.