Aperture Script - Can't replicate user problem
Aperture Script - Can't replicate user problem
- Subject: Aperture Script - Can't replicate user problem
- From: John <email@hidden>
- Date: Mon, 04 Feb 2013 20:30:43 -0500
I wrote this script to rename and File Aperture projects by date :
http://www.johneday.com/9/rename-and-file-aperture-projects-by-date .
A Mountain Lion user has given me this feedback:
"OK, so I get the error that the EXIF tag does not have capture year. I'm on Mountain Lion, and recall that it worked on one project the very first time I ran the script after downloading and installing it... it's almost as if some flag gets set to true or false and it needs to be reset."
Can anyone running Mountain Lion replicate this problem for me? Any insights about what is going wrong for him would be appreciated.
set yourFolder to "Imported by Date" -- Name your folder here
set appendParent to false -- If true, the selected parent's name will be appended to the new project name
set makeSubfolders to false -- If true, new projects will be created in year/month/ folders.
property delimiter : "-"
try
tell application "Aperture"
activate
-- Wait until Aperture is finished processing other tasks
repeat
set taskCount to count of tasks
if taskCount is 1 then
display alert "Aperture is processing another task" message "Please wait for the task to complete and try again" buttons {"Try again", "Cancel"} default button {"Try again"} cancel button {"Cancel"}
else if taskCount > 1 then
display alert "Aperture is processing " & taskCount & " tasks" message "Please wait for the tasks to complete and try again" buttons {"Try again", "Cancel"} default button {"Try again"} cancel button {"Cancel"}
else
exit repeat
end if
end repeat
-- Verify that at least one item is selected
if selection is {} then display alert "The selection {} is empty" message "Please select ONE Project, Folder or Album from the Library tab in the sidebar and try again." buttons {"OK"} cancel button {"OK"}
-- Get the selected Parent ID
tell item 1 of (selection as list) to set theParent to parent
set {parentClass, parentName} to {class, name} of theParent
if parentClass is album then display dialog "Albums may contain images from multiple projects. Are you sure you want to move these images from their projects?"
-- Get date of every image in the selected Parent
tell theParent to set dateList to every image version's (value of EXIF tag "ImageDate")
tell library 1
-- Create your folder if it does not exist
if not (exists folder yourFolder) then make new folder with properties {name:yourFolder}
-- Assign name of every project in your folder to a list for the Create project command below
-- (exists project isoImageDate) command is too slow to be included in the loop
if not makeSubfolders then tell folder yourFolder to set parentList to name of every project
set dateTest to {}
repeat with aDate in my dateList
-- Test each date to avoid processing duplicates
set shortDate to short date string of aDate
if dateTest does not contain shortDate then
set end of dateTest to shortDate
-- Convert the image date to YYYY-MM-DD format
set projectYear to year of aDate as string
set projectMonth to (month of aDate as integer) as string
if length of projectMonth is 1 then set projectMonth to "0" & projectMonth
set projectDay to (day of aDate as integer) as string
if length of projectDay is 1 then set projectDay to "0" & projectDay
set isoImageDate to projectYear & delimiter & projectMonth & delimiter & projectDay as string
if appendParent then set isoImageDate to isoImageDate & space & parentName
tell folder yourFolder
if makeSubfolders then
--Create year and month folders if year folder does not exist
if not (exists folder projectYear) then make new folder with properties {name:projectYear}
tell folder projectYear
if not (exists folder projectMonth) then make new folder with properties {name:projectMonth}
end tell
--Create project if it does not exist
if ((name of every project of folder projectMonth of folder projectYear) does not contain isoImageDate) then tell folder projectMonth of folder projectYear to make new project with properties {name:isoImageDate}
-- Move the images into the project
move (every image version of theParent whose value of EXIF tag "CaptureYear" is year of aDate and value of EXIF tag "CaptureMonthOfYear" is month of aDate as integer and value of EXIF tag "CaptureDayOfMonth" is day of aDate) to project isoImageDate of folder projectMonth of folder projectYear
else -- If not makeSubfolders
--Create project if it does not exist
if parentList does not contain isoImageDate then make new project with properties {name:isoImageDate}
-- Move the images into the project
move (every image version of theParent whose value of EXIF tag "CaptureYear" is year of aDate and value of EXIF tag "CaptureMonthOfYear" is month of aDate as integer and value of EXIF tag "CaptureDayOfMonth" is day of aDate) to project isoImageDate
end if
end tell
end if
end repeat
-- Move the initial container to the Trash if no images remain or if it is an album
if parentClass is album then
delete theParent
else if (count of image versions of theParent) is 0 then
delete theParent
end if
beep
end tell
end tell
on error errMsg number errNum
tell me
activate
display alert errMsg & return & return & "Error number" & errNum buttons "Cancel"
end tell
end try
EXIF Tag Name Mapping:
The following table provides a mapping between EXIF tag names found in the Aperture 3 interface and EXIF tag names that appear in AppleScript.
http://i.imgur.com/iDQSkFk.png
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden