Writing iPhoto Exif Data

Here is some quick Applescript that uses ExifTool to write Copyright, Title, Comments, and Keyword exif data to selected photos in iPhoto:

This script is released under the Creative Commons.

-- This applescript will set the exif keywords, name,
-- and comments of all selected iPhoto images using
-- the information current in iPhoto.
-- Author: Andrew Turner (http://highearthorbit.com)
property copyright : ¬
"Copyright Andrew Turner, 2005. All Rights Reserved."
property URL : "http://highearthorbit.com"
property exifToolOriginal : "_original"

-- True retains copyright, False means Public Domain
property Copyrighted : "True"

tell application "iPhoto"
copy (my selected_images()) to these_images
if these_images is false or (the count of these_images) ¬
is 0 then ¬
error "Please select a single image."

repeat with i from 1 to the count of these_images
set the keywordslist to ""
set this_photo to item i of these_images
tell this_photo
set the image_file to the image path
set the image_title to the title
set the image_filename to the image filename
set the image_comment to the comment
set the assigned_keywords to the name of keywords
end tell
repeat with j from 1 to the count of assigned_keywords
set the keywordslist to keywordslist & " -keywords+=" ¬
& item j of assigned_keywords
end repeat
set output to do shell script ¬
"exiftool -title='" & image_title & ¬
"' " & keywordslist & ¬
" " & " -comment='" & image_comment & ¬
"' " & " -Copyright='" & copyright & ¬
"' " & " -CopyrightNotice='" & copyright & ¬
"' " & " -Rights='" & copyright & ¬
"' " & " -Marked='" & Copyrighted & ¬
"' " & "'" & image_file & "'"
do shell script "rm '" & image_file & "'" ¬
& exifToolOriginal
end repeat

display dialog "Exif writing complete."
on error error_message number error_number
if the error_number is not -128 then
display dialog error_message buttons {"Cancel"} ¬
default button 1
end if
end try
end tell

on selected_images()
tell application "iPhoto"
-- 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

You can grab this script and a simpler Copyright only, as well as a Location (latitude/longitude/city,region,country) script here.

About this article

written on
posted in ProgrammingPhotographyApplescript Back to Top

About the Author

Andrew Turner is an advocate of open standards and open data. He is actively involved in many organizations developing and supporting open standards, including OpenStreetMap, Open Geospatial Consortium, Open Web Foundation, OSGeo, and the World Wide Web Consortium. He co-founded CrisisCommons, a community of volunteers that, in coordination with government agencies and disaster response groups, build technology tools to help people in need during and after a crisis such as an earthquake, tsunami, tornado, hurricane, flood, or wildfire.