Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- Rename Aperture Projects
- This script loops through each project located within the "Events" folder in Aperture. For each project
- found, all photos within are examined, and the oldest photo's date is used to rename the project to the
- format "YYYY-MM-DD | Previous_Project_Name". This script can be used each time you import, and then
- the projects can be moved to other folders. Make sure you have just one "Events" folder in your library
- (even in the Trash folder).
- © 2011,2012 Tim Doyle, timdoyletx at gmail dot com
- -- modified by Alex Gorbachev 15-Dec-2012 (folder name dialog + last date addition)
- *)
- on formatData(_theDate)
- set _tday to day of _theDate as number
- if _tday < 10 then
- set _day to "0" & (_tday as string)
- else
- set _day to _tday as string
- end if
- set _tmonth to month of _theDate as number
- if _tmonth < 10 then
- set _month to "0" & (_tmonth as string)
- else
- set _month to _tmonth as string
- end if
- set _year to year of _theDate as string
- return _year & "-" & _month & "-" & _day
- end formatData
- --set rootFolder to display dialog "Enter folder name" default answer "Events"
- tell application "Aperture"
- activate
- set rootFolder to "Events"
- display dialog "Enter folder name" default answer rootFolder
- set rootFolder to text returned of result
- tell library 1
- set _projects to every project in folder rootFolder
- repeat with p from 1 to count of _projects
- tell item p of _projects
- set projectName to name
- end tell
- --display dialog "PN=" & projectName
- tell current application
- if (offset of "|" in projectName) > 0 then
- set eventName to text ((offset of "|" in projectName) + 2) thru (length of projectName) of projectName
- else
- set eventName to projectName
- end if
- end tell
- --display dialog "EN=" & eventName
- set _versions to every image version in item p of _projects
- set minImageDate to ""
- set maxImageDate to ""
- repeat with v from 1 to count of _versions
- tell item v of _versions
- set thisImageDate to value of EXIF tag "ImageDate"
- set thisImageDate to thisImageDate - (time of thisImageDate)
- end tell
- if (minImageDate = "") then
- set minImageDate to thisImageDate
- else
- if (thisImageDate < minImageDate) then
- set minImageDate to thisImageDate
- end if
- end if
- if (maxImageDate = "") then
- set maxImageDate to thisImageDate
- else
- if (thisImageDate > maxImageDate) then
- set maxImageDate to thisImageDate
- end if
- end if
- end repeat
- if minImageDate = maxImageDate then
- set _name to formatData(minImageDate) of me & " | " & eventName
- else
- set _name to formatData(minImageDate) of me & " | " & eventName & " <" & formatData(maxImageDate) of me
- end if
- --display dialog "Would have renamed " & projectName & " to " & _name
- tell item p of _projects
- set name to _name
- end tell
- end repeat
- end tell
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement