METADATA
Note: The scripts on this site are provided as is and I am unable to provide any technical assistance. Backup all data before using any of the scripts this site provides.
In this section I provide sample scripts that handle metadata in Aperture using Applescript.
The
names of the metadata tags are sometimes different than the names
that appear in the GUI. This script is great at getting all of the
available Exif tags from an image. You can do the same with IPTC,
Keywords, and Custom metadata tags.
tell
application
"Aperture"
tell library
1
tell project
"untitled
project"
tell image version
1
get name
of EXIF tags
--will only return
available exif tags for this particular image, not all available
exif tags because if there is no value for the tag, then the class
hasn't been created
end
tell
end
tell
end
tell
end
tell
In order to retrieve or set a value to a metadata tag, the class representing that tag must first exist. For instance, an image named "image001" does not have a value for the Shutter Speed field. If you ask for the value of Exif tag "ShutterSpeed" of image "image001", your script will produce an error. The reason is there is no such tag to ask its value.
Get
the value of a particular tag from a particular image (again,
assuming the tag class exists for the particular
image).
tell
application
"Aperture"
tell library
1
tell project
"untitled
project"
tell image version
"image001"
get value
of IPTC tag
"Caption/Abstract"
end
tell
end
tell
end
tell
end
tell
The Applescript dictionary of Aperture reveals that, only IPTC, Keyword, and Custom tags are capable of reading and setting a value.
When
to use "set" and when to use "make new".
tell
application
"Aperture"
tell library
1
tell project
"untitled
project"
tell image version
"image001"
--set value of IPTC
tag "Caption/Abstract" of image version "Canon 1Ds" to
"hello"
--the above won't work
IF the tag doesn't already have a value because the class doesn't
exist until it does. Therefore you have to make the class then set
its value. See the next tell block.
end
tell
tell image version
"image001"
make new IPTC tag
with
properties {name:"Caption/Abstract",
value:"hello"}
--this line will work
every time even if a value for the tag exists or
not.
end
tell
end
tell
end
tell
end
tell
There is also a way to set a value of a particular tag to every image in a project.
You
tell every image to make the new tag as in this example. This
happens to be much faster than running through a list and issuing a
"make new" command to each individual image.
tell
application
"Aperture"
tell library
1
tell project
"untitled
project"
tell
every image
version
make new IPTC tag
with
properties {name:"CopyrightNotice", value:"My Name"}
end
tell
end
tell
end
tell
end
tell
New to Aperture 2.0 is the ability to export masters with IPTC embedded within the raw file itself. For more on exporting images, see the Exporting section of this web site.
Also new to Aperture 2.0 is the ability to change the date the image was taken.
I see two possible approaches to changing a date: "time shifting" and "time stamping". Time shifting is moving a particular date field by a certain amount such as August 19, 2007 +5 years = August 19, 2012. Time stamping is stamping a particular date down on an image regardless of the image's current date such as applying July 30, 2000 to all your images. Each approach has its uses. Personally I like using "time stamping" because with its use I known each image's date and they are all the same so there is no confusion. Use the approach that works best for your needs.
Simple
Time Shifting script. This increments the year of every selected
image by 3.
set
image_selection
to {}
tell
application
"Aperture"
set image_selection
to selection
repeat
with i
from 1
to count
of image_selection
tell item i
of image_selection
set imageDate
to value
of EXIF tag
"ImageDate"
end
tell
set year
of imageDate
to ((year
of imageDate)
+ 3)
--previous line will
allow you to increment the year of the date of each selected image
version.
--of course you can
change it so its the day or month, etc as well as change the amount
(forward or back in time)
adjust image date
imageDate
of
images {item i
of image_selection}
end
repeat
end
tell
Simple
Time Stamping script. Give the script any date you would like to
have stamped on all the selected images.
tell
application
"Aperture"
set x
to selection
set currDate
to date "Monday January 29, 2001 10:00:00
AM"
adjust image date
currDate
of
images x
end
tell
This
script provides a very simple and basic GUI so that you can prompt
the user for a date instead of hard coding it in the script each
time you want to use a different date. Also, it prompts the user to
apply the date change to only versions (leaving the masters alone).
The other option is apply the date change to versions and master
files.
set
imageSelection
to {}
set
userDate
to ""
--------------------------------------------------
repeat
until class
of userDate
is date
set userReturned
to (display dialog
"enter full date &
time" default answer
"Monday January 29, 2001
10:00:00 AM" buttons
{"Version",
"Master",
"Cancel"}
default
button "Cancel")
set userDate
to text returned
of userReturned
try
set userDate
to (date userDate)
end
try
end
repeat
set
userButton
to button returned
of userReturned
--------------------------------------------------
tell
application
"Aperture"
set imageSelection
to selection
if userButton
is "Version"
then
adjust image date
userDate
of
images imageSelection
else
if userButton
is "Master"
then
adjust image date
userDate
of
images imageSelection
with masters
included
end
if
end
tell
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------
on
testUserDate(x)
if class
of x
is date
then
return true
else
return false
end
if
end
testUserDate
