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

Click here to return to the 'Set photo titles to picture capture date in iPhoto' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set photo titles to picture capture date in iPhoto
Authored by: robleach on Mar 11, '10 09:27:31AM
Cool hint. I made a modification to make the date a little more readable, but still sortable (though I took out the seconds).
tell application "iPhoto"
	--  activate -- bring iPhoto back to front
	copy (my selected_images()) to these_images
	if these_images is {} then error "Please select some images before using this script."
	set thename to ""
	set thepaths to ""
	set thedates to ""
	repeat with i from 1 to the count of these_images
		set this_image to item i of these_images
		--set this_file to the image path of this_image    
		set thename to thename & ", " & the title of this_image
		--set thepaths to thepaths & the image path of this_image & ", "
		set thedate to the date of this_image
		set theyear to the year of thedate
		set themonth to my format(the month of thedate as number)
		set theday to my format(the day of thedate)
		set themins to my format(the minutes of thedate)
		set thehours to my format(the hours of thedate)
		set thetod to "am"
		if (thehours as number) > 12 then
			set thetod to "pm"
			set thehours to ((thehours as number) - 12)
		end if
		set thetitle to theyear & "/" & themonth & "/" & 
			theday & " at " & thehours & ":" & themins & thetod
		--set thedates to thedates & thetitle & ", "
		set the title of the item i of these_images to thetitle as string
	end repeat
end tell

on selected_images()
	tell application "iPhoto"
			set these_items to the selection
			if the class of item 1 of these_items is album then error
			return these_items
		on error
			return {}
		end try
	end tell
end selected_images

on format(thenumber)
	if (thenumber as number) < 10 then
		set res to "0" & (thenumber as string)
		set res to thenumber as string
	end if
	return res
end format

[ Reply to This | # ]