iPhoto: select photos in album A and NOT in album B

Hi all -

Thanks in advance for any help you can offer with this. I would like to have a way to find photos in iPhoto that are in one album (Album A) and NOT in another (Album B). One of the “albums” is a web gallery. The Smart Albums feature in iPhoto ('08) does not show web galleries in the selection list so I can’t make a Smart Album to show photos NOT in the web gallery. In Automator, the web galleries DO show up in the list but I can only choose “album IS” not “album IS NOT”. So, I’ve been trying Applescript but I can’t seem to get it to work. I can set a variable to every photo in the library or in an album and I can select from those variables, but I haven’t been able to selection based on non-membership in an album.

Here’s are some samples of what I’ve tried:

tell application “iPhoto”
set allPhotos to every photo of photo library album – this works
set firstSelection to every photo of album “Album A” – this works, even with a web gallery album
set secondSelection to every photo of album “Album B”-- this works, even with a web gallery album
set theSelection to every photo of photo library album whose album is not “Imported” – Script Editor errors reporting “iPhoto got an error: Can’t make album into type reference.”

I’ve also tried to find some syntax to find photos in firstSelection and not in secondSelection but it never compiles.

Can someone help me out?

Thanks much.

Model: PowerBook G4
AppleScript: 2.2
Browser: Safari 523.10
Operating System: Mac OS X (10.5)

Hi,

you can get the photos of album A, which are not in album B, only with a repeat loop like this:


tell application "iPhoto"
	set Photos_Of_A_Not_in_B to {}
	tell photos of album "A" to set {firstSelection, firstID} to {it, id}
	set secondID to id of photos of album "B"
	repeat with i from 1 to count firstSelection
		if item i of firstID is not in secondID then set end of Photos_Of_A_Not_in_B to item i of firstSelection
	end repeat
end tell
Photos_Of_A_Not_in_B -- list of photos of "A", which are not in "B"

this cannot work, because the element photo has no property album

Thanks so much. I was under the impression that photos had album attributes the way they have date attributes. Thanks for clearing that up.

Regarding your loop and results, how can I turn that into a selection in iPhoto so that I can move them into another album?

Thanks again.

  • John

The easiest way is to do it directly


tell application "iPhoto"
	tell photos of album "A" to set {firstSelection, firstID} to {it, id}
	set secondID to id of photos of album "B"
	repeat with i from 1 to count firstSelection
		if item i of firstID is not in secondID then add item i of firstSelection to album "C"
	end repeat
end tell

That worked perfectly - thanks.