We've finished our move from .Mac to our very own domain
name: http://www.brettgrossphotography.com/ .
Woo hoo!
Back Up Masters
Current
version: v3 14
Built on: Aperture 1.5.2
This AppleScript operates on the selection, a project or
album.
Download
This AppleScript takes the selection, an album, or a
project of your choice and exports the master images (with
XMP sidecar files) into approximately DVD-sized folders –
creating as many as needed. It can be a little slow as it
exports each master individually, but it works and allows
you to use any folder export setting you have in Aperture.
It will also tag exported images with a keyword to indicate
that they were backed up and the name of the disc they were
backed up to (as long as you burn the resulting folder(s)).
--
---------------------------------------------------------------------------------------------------------------------------
property
p_splitSizeMB : 4600
property
p_discName : "Backup"
property
p_keywordPath : "DVD_Backup Workflow"
--
---------------------------------------------------------------------------------------------------------------------------
global
g_libPath
global
g_totalSize
global
g_discCount
global
g_masterPaths
global
g_masterSizes
global
g_masterNames
global
g_albumSizeMB
--
---------------------------------------------------------------------------------------------------------------------------
on
run
set
g_totalSize
to
0
set
g_discCount
to
1
set
g_masterPaths
to
{}
set
g_masterSizes
to
{}
set
g_masterNames
to
{}
tell
application
"Aperture"
activate
--
-------------------------------------------- Choose our
source
set
theOut
to
display dialog
"Back up selected images or of a Project or Album?"
buttons
{"Selection", "Project/Album", "Cancel"}
default button
2
with icon
note
set
theSource
to
button returned
of
theOut
if
theSource
is
"Selection"
then
set
m_images
to
selection
set
m_numImgs
to
count
of
m_images
set
m_desc
to
"selection"
else
set
m_theSource
to
my
chooseProjAlbum()
set
m_theKind
to
(class
of
m_theSource)
as
string
set
m_srcName
to
name
of
m_theSource
set
m_desc
to
(m_theKind &
space
&
quoted form
of
m_srcName)
as
string
set
m_images
to
(image
versions
of
m_theSource)
set
m_numImgs
to
count
of
m_images
end
if
--
-------------------------------------------- Set up our
destination folder
--tell
AppleScript
set
destRoot
to
choose folder
with prompt
"Choose a folder to export into:"
--end
tell
tell
application
"Finder"
set
curDate
to
current date
set
m_dateStr
to
my
formatDate(curDate)
--
--------------------------------------------------- Make
our destination root folder
set
numExports
to
(count
of
(folders
of
destRoot
whose
name
contains
m_dateStr))
set
m_exportName
to
(m_dateStr & "_" & (numExports + 1))
as
string
set
destPar
to
make
new
folder
at
destRoot
with properties
{name:m_exportName}
--set
m_discName to (p_discName & space &
g_discCount)
set
m_destRoot
to
make
new
folder
at
destPar
with properties
{name:(p_discName
& "_" & m_exportName & "_" & g_discCount)}
set
m_destRootAlias
to
(m_destRoot
as
alias)
end
tell
set
m_exportSettingsNames
to
(name
of
every
export setting)
set
m_folderNamingPolicies
to
(name
of
every
folder naming policy)
set
m_fileNamingPolicies
to
(name
of
every
file naming policy)
--tell
AppleScript
--
set theOut to choose from list m_exportSettingsNames with
prompt "Choose export settings"
set
theOut
to
choose from list
m_folderNamingPolicies
with prompt
"Choose folder naming settings"
set
m_chosenNamingPolicies
to
(item
1
of
theOut)
--
set theOut to choose from list m_fileNamingPolicies with
prompt "Choose file naming settings"
--end
tell
(*
tell AppleScript
display dialog ("This will take some time. Expect
approximately 5 seconds per image for a total estimated
time of " & ((count of m_images) * 5) & " seconds")
buttons {"OK"} default button 1 with icon note
end tell
*)
set
m_curImageSet
to
{}
repeat
with
m_curImage
in
m_images
set
imgNameRAW
to
name
of
m_curImage
log
imgNameRAW
if
imgNameRAW
contains
"Version"
then
set
theOffset
to
offset
of
"Version"
in
imgNameRAW
set
trimName
to
(text
1
thru
(theOffset - 4)
of
imgNameRAW)
log
trimName
set
imgName
to
trimName
else
set
imgName
to
imgNameRAW
end
if
if
g_masterNames
does not
contain
imgName
then
set
end
of
m_curImageSet
to
m_curImage
set
end
of
g_masterNames
to
imgName
set
g_totalSize
to
size
of
(info
for
m_destRootAlias)
log
g_totalSize
--
Here is where the magic happens
--
If our current size is greater than about 4.6GB we'll
export the current images
if
g_totalSize < (p_splitSizeMB * 1000000)
then
log
"----------------------------------- exporting master"
export
{m_curImage}
to
m_destRootAlias
naming folders with
(folder
naming policy
m_chosenNamingPolicies)
with
metadata
else
--
---------------------------------- create a new destination
folder
log
"----------------------------------- creating new
destination"
tell
application
"Finder"
set
g_discCount
to
g_discCount + 1
--set
m_discName to (p_discName & space &
g_discCount)
set
m_destRoot
to
make
new
folder
at
destPar
with properties
{name:(p_discName
& "_" & m_exportName & "_" & g_discCount)}
set
m_destRootAlias
to
(m_destRoot
as
alias)
end
tell
log
"----------------------------------- exporting master"
export
{m_curImage}
to
m_destRootAlias
naming folders with
(folder
naming policy
m_chosenNamingPolicies)
with
metadata
end
if
--
---------------------------------- Mark the image as having
been backed up
set
m_backKey
to
(m_exportName & "_" & g_discCount)
as
string
my
addKey(m_curImage, m_backKey, p_keywordPath)
end
if
end
repeat
end
tell
tell
application
"Finder"
activate
open
destPar
end
tell
end
run
--
---------------------------------------------------------------------------------------------------------------------------
on
addKey(s_imgVers, s_theKey, s_keyParents)
log
s_theKey
log
s_keyParents
tell
application
"Aperture"
tell
s_imgVers
make
new
keyword
with properties
{name:s_theKey,
parents:s_keyParents}
end
tell
end
tell
end
addKey
--
---------------------------------------------------------------------------------------------------------------------------
on
formatDate(theDate)
--
formatDate 01.0
set
theMonth
to
(month
of
theDate)
as
integer
if
theMonth
is
less than
10
then
set
theMonth
to
("0" & theMonth
as
string)
as
string
set
theDay
to
(day
of
theDate)
if
theDay
is
less than
10
then
set
theDay
to
("0" & theDay
as
string)
as
string
set
theYear
to
(year
of
theDate)
set
theHour
to
time
of
theDate
set
dateStr
to
((theMonth
as
string)
& "-" & (theDay
as
string))
set
dateStr
to
(((theYear
as
string)
& "-" & (theMonth
as
string)
& "-" & (theDay
as
string)))
--
& " " & (theHour))
--
set dateStr to (((theYear as string) & "-" &
(theMonth as string) & "-" & (theDay as string))
& " " & (theHour))
return
dateStr
end
formatDate
--
---------------------------------------------------------------------------------------------------------------------------
on
chooseProjAlbum()
tell
application
"Aperture"
set
theLib
to
library
1
set
theProjects
to
projects
set
theProjectsNames
to
{}
repeat
with
curProject
in
theProjects
set
end
of
theProjectsNames
to
name
of
curProject
end
repeat
tell
AppleScript
to
set
theOut
to
choose from list
theProjectsNames
with prompt
"Choose a project:"
set
theProject
to
project
(item
1
of
theOut)
--set
theProject to project "Bretts Portfolio"
set
theAlbums
to
albums
of
theProject
if
theAlbums
is
{}
then
set
theAlbum
to
theProject
else
set
formProjName
to
("<" & (name
of
theProject) & ">")
set
theAlbumNames
to
{formProjName}
repeat
with
curAlbum
in
theAlbums
set
end
of
theAlbumNames
to
name
of
curAlbum
end
repeat
tell
AppleScript
to
set
theOut
to
choose from list
theAlbumNames
with prompt
"Choose an album or the project:"
if
((item
1
of
theOut) = (item
1
of
theAlbumNames))
then
set
theAlbum
to
theProject
else
set
theAlbum
to
album
(item
1
of
theOut)
of
theProject
end
if
end
if
return
theAlbum
end
tell
end
chooseProjAlbum