Camelot wrote:
repeat with i from 1 to count of items in exportFolder
What is 'exportFolder'? Where is it defined?
Thanks, 'exportFolder' is defined earlier in the script. The purpose of the script - which is run from within Aperture - is to rename the selected images, export them (to the 'exportFolder'), reset the version name and, using ExifTool, add metadata which Aperture does not write to exported JPEGs.
I have a version of this which works in Automator but I couldn't see any clues there on setting the path to ExifTool.
Here's the full (modified) script. Currently it returns an error
Result:
error "No file specified" number 1
so I now need to understand if I can use 'exportFolder' (defined at the start) to tell Finder which folder to use.
* * *
-- Creating filenames by making Version Name from the IPTC Headline and Filename (with hypens where spaces exist). The Aperture Version Name is used to create the file's name on export. Once exported the Aperture Version Name is reset to its original.
tell application "System Events"
set exportFolder to (choose folder with prompt "Choose an export folder")
end tell
tell application "Aperture"
set theSel to (get selection)
if theSel is {} then
error "Please select an image or two!."
else
repeat with theImg in theSel
-- Creating a new Aperture Version Name which will become the exported file's filename.
tell theImg
set headline to (get value of IPTC tag "Headline" of theImg)
set AppleScript's text item delimiters to " "
set theTextItems to text items of headline
set AppleScript's text item delimiters to "-"
set headline to theTextItems as string
set AppleScript's text item delimiters to {""}
set objectName to (get value of IPTC tag "ObjectName" of theImg)
set newVersion to (headline & "-" & objectName) as string
set name of theImg to newVersion
end tell
end repeat
-- Exporting the files as JPEGs to chosen folder/Project Name using the Version Name as a filename
export theSel using export setting "JPEG - Original Size" to exportFolder
-- Resetting the Aperture Version Name back to filename using IPTC Title (which should be the file's filename without suffex).
repeat with theImg in theSel
tell theImg
set title to (get value of IPTC tag "ObjectName" of theImg)
set name of theImg to title
end tell
end repeat
end if
end tell
--Using ExifTool to set Photoshop Copyright Status etc
tell application "Finder" to set theFiles to files of exportFolder as alias list
repeat with eachFile in theFiles
do shell script "/usr/bin/exiftool -overwrite_original -Photoshop:CopyrightFlag='True' -Photoshop:URL='http://davidgordon.co.uk/'" & quoted form of POSIX path of eachFile
end repeat
display dialog "Done that!" with iconnotebuttons "OK" default button 1 giving up after 10
* * *