iPhoto - stepping through an album

If I have one photo selected in iPhoto (current selection), how do I select the next photo? I want edit that photo, maybe enter some comments and then move to the next photo. Do I have to select all the photos in the album to begin stepping item by item (photo by photo)?

some things that don’t work…

select photo after last item of selPhotos – where selPhotos is a range of Photos

select photo after selection

select next photo

Model: Power Mac G5
AppleScript: ?
Browser: Safari 533.18.5
Operating System: Mac OS X (10.5)

for some reason the following script never executes the repeat loop…


tell application "iPhoto"
	
	set the_Photos to photos of last rolls album
	set the photo_count to the count of photos of the_Photos
	repeat with i from 1 to the photo_count
		set this_photo to photo i of last rolls album
		display dialog "continue?"
		
	end repeat
end tell

The dialog never appears. I thought this might actually accomplish what I needed. Why doesn’t the loop execute?

A small change got the repeat loop to execute…


tell application "iPhoto"
	
	set the_Photos to photos of last rolls album
	set the photo_count to the count of items in the_Photos
	repeat with i from 1 to the photo_count
		set this_photo to photo i of last rolls album
		set comment of this_photo to "testing"
		display dialog "continue?"
		
	end repeat
end tell


Now, how do I get iPhoto to step to the next photo and display it?

Once the script below executes the line “select this_photo” the selection is reduced to one and it will not step to the next photo of the original selection, since it no longer exists.



tell application "iPhoto"
	set myPhotos to selection
	display dialog (count of myPhotos)
	repeat with i from 1 to (count of myPhotos)
		set this_photo to item i of myPhotos
		select this_photo
		set view to edit
		display dialog "continue?"
		
	end repeat
end tell


Can someone show me how to view photos one by one to allow editing? I want to add comments from a dialog choice list of comments.

I’ve had enough tonight… bedtime.

Hi,

you don’t need to select a photo visibly to assign a comment


tell application "iPhoto" to set myPhotos to photos of last rolls album
repeat with onePhoto in myPhotos
	set {text returned:textReturned} to display dialog "Enter comment" default answer ""
	tell application "iPhoto" to set comment of contents of onePhoto to textReturned
end repeat

or a ‘list’ version


property commentList : {"comment1", "comment2", "comment3"}

tell application "iPhoto" to set myPhotos to photos of last rolls album
repeat with onePhoto in myPhotos
	set chosenComment to choose from list commentList
	if chosenComment is not false then
		tell application "iPhoto" to set comment of contents of onePhoto to item 1 of chosenComment
	end if
end repeat


StefanK

Thanks… Yes, I am aware of entering the comment without actually “seeing” the photo, but I need to see the photo in order to select the correct comment from the list. That is my dilemma.

There must be some way to move the selection to the next photo. I’m sure it’s simple, I just don’t get it. Applescript, you just gotta love it! Applescript, you just gotta hate it!

fortunately iPhoto is one of the few Apple applications, which respond to the select command


property commentList : {"comment1", "comment2", "comment3"}

tell application "iPhoto" to set myPhotos to photos of last rolls album
repeat with onePhoto in myPhotos
	tell application "iPhoto" to select onePhoto
	set chosenComment to choose from list commentList
	if chosenComment is not false then
		tell application "iPhoto" to set comment of contents of onePhoto to item 1 of chosenComment
	end if
end repeat

I still cannot get iPhoto to step through the displayed photo. Here is another attempt. Notice the system events line. I thought by calling this the next photo would be displayed just like pressing the right arrow on the keyboard. Maybe I don’t have something set in system preferences.


property commentList : {"comment1", "comment2", "comment3"}

tell application "iPhoto" to set myPhotos to photos of last rolls album
tell application "iPhoto" to set view to edit
repeat with onePhoto in myPhotos
	tell application "iPhoto" to select onePhoto
	tell application "System Events" to keystroke (ASCII character 29) --right arrow
	set chosenComment to choose from list commentList with prompt "Choose some" OK button name "Next" cancel button name "Cancel" with multiple selections allowed
	display dialog "1"--to cancel out of loop before end of repeat
	if chosenComment is not false then
		display dialog "2"--to check execution
		
		set oldDelims to AppleScript's text item delimiters -- save their current state
		set AppleScript's text item delimiters to {", "}
		set thecomment to chosenComment as string
		set AppleScript's text item delimiters to oldDelims -- restore them
		tell application "iPhoto"
			if comment of onePhoto is equal to "" then
				set comment of onePhoto to thecomment
			else
				set comment of onePhoto to (comment of onePhoto & ", " & thecomment)
			end if
			
			--tell application "iPhoto" to set comment of contents of onePhoto to item 1 of chosenComment
		end tell
	end if
end repeat

very strange. On my machine (10.6 and iPhoto 11) the script selects the photos properly

I just set the “Enable access for assistive devices” option to checked in the “Universal Access” System Preference. I thought that might fix this, but it didn’t.