Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Perhaps this is a starting point...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Perhaps this is a starting point...
Authored by: jecwobble on Aug 20, '04 12:53:12AM
I wrote this (with much plagiarism) a while back for use with MyPhoto before I realized that the comments of the newer versions of iPhoto won't work with MyPhoto. It copies a photo's keywords to it's comments. Maybe you could "reverse" engineer it, so to speak.

try
	tell application "iPhoto"
		activate
		copy (my selected_images()) to these_images
		if these_images is false then ¬
			error "Please select the images to copy keywords to comments."
		
		display dialog "Copy keywords to comments?"
		
		set the image_count to the count of these_images
		
		-- Comment out this dialog if you want to just start copying
		display dialog "Processing " & (the image_count as string) & " photos." & return & return & "This may take some time.." buttons {"•"} default button 1 giving up after 3
		
		repeat with i from 1 to the image_count
			set this_photo to item i of these_images
			tell this_photo
				if comment contains "Keywords: " then
					-- Comment out this dialog if you don't want it
					display dialog title & " already has keywords in comments" buttons {"•"} default button 1 giving up after 2
				else
					set the image_keywords to ""
					repeat with kc from 1 to count of keywords
						if kc is equal to (count of keywords) then
							-- The last keyword doesn't need a semicolon after it
							set the image_keywords to image_keywords & the name of keyword kc
						else
							set the image_keywords to image_keywords & the name of keyword kc & "; "
						end if
					end repeat
					if comment is not "" then
						-- Preserve existing comments
						set comment to comment & return & "Keywords: " & image_keywords
					else
						set comment to "Keywords: " & image_keywords
					end if
				end if
			end tell
		end repeat
		display dialog "Finished processing " & (the image_count as string) & " photos." buttons {"•"} default button 1 giving up after 3
	end tell
on error error_message number error_number
	tell application "iPhoto"
		activate
		if the error_number is not -128 then
			display dialog error_message buttons {"OK"} default button 1
		end if
	end tell
end try

on selected_images()
	tell application "iPhoto"
		try
			-- get selection
			set these_items to the selection
			-- check for single album selected
			if the class of item 1 of these_items is album then error
			-- return the list of selected photos
			return these_items
		on error
			return false
		end try
	end tell
end selected_images


[ Reply to This | # ]