Exporting From Aperture With Applescript
2006-08-23
User ramonr posted the script below on the Apple Aperture forums. It exports all your images that are in albums in the project you choose. I've not tried it myself.
I have a generalized script - it assumes that any pictures are in albums (rather than in just subfolders) but it will walk you down as many levels as you have.
tell application "Finder"
set location_1 to (choose folder with prompt "Choose a folder to export into") as text
end tell
tell application "Aperture"
set x to name of every project
choose from list x with prompt "Choose a project to export"
set theP to item 1 of result
tell application "Finder" to make new folder at alias location_1 with properties {name:theP}
tell project theP
set initflist to every subfolder
set initalist to every album
if initflist is equal to {} then
processAlbums(initalist, location_1 & theP) of me
else
if initalist is not equal to {} then
processAlbums(initalist, location_1 & theP) of me
end if
processSfolders(initflist, (location_1 & theP)) of me
end if
end tell
end tell
on processAlbums(alist, apath)
tell application "Aperture"
repeat with a in alist
tell a
set theimages to every image version as list
set thename to name of a
tell application "Finder"
if not (exists folder thename in alias apath) then
make new folder at alias apath with properties {name:thename}
end if
set destination to apath & ":" & thename & ":"
end tell
with timeout of 6000 seconds
tell a
set settings to "JPEG - Original Size"
export theimages using settings to alias destination
end tell
end timeout
end tell
end repeat
end tell
end processAlbums
on processSfolders(flist, fpath)
tell application "Aperture"
repeat with a in flist
set thename to name of a
tell application "Finder"
if not (exists folder thename in alias fpath) then
make new folder at alias fpath with properties {name:thename}
end if
end tell
tell a
set sAlist to every album
set sflist to every subfolder
if sflist is equal to {} then
processAlbums(sAlist, fpath & ":" & thename) of me
else
if sAlist is not equal to {} then
processAlbums(sAlist, fpath & ":" & thename) of me
end if
processSfolders(sflist, fpath & ":" & thename) of me
end if
end tell
end repeat
end tell
end processSfolders
I have a generalized script - it assumes that any pictures are in albums (rather than in just subfolders) but it will walk you down as many levels as you have.
tell application "Finder"
set location_1 to (choose folder with prompt "Choose a folder to export into") as text
end tell
tell application "Aperture"
set x to name of every project
choose from list x with prompt "Choose a project to export"
set theP to item 1 of result
tell application "Finder" to make new folder at alias location_1 with properties {name:theP}
tell project theP
set initflist to every subfolder
set initalist to every album
if initflist is equal to {} then
processAlbums(initalist, location_1 & theP) of me
else
if initalist is not equal to {} then
processAlbums(initalist, location_1 & theP) of me
end if
processSfolders(initflist, (location_1 & theP)) of me
end if
end tell
end tell
on processAlbums(alist, apath)
tell application "Aperture"
repeat with a in alist
tell a
set theimages to every image version as list
set thename to name of a
tell application "Finder"
if not (exists folder thename in alias apath) then
make new folder at alias apath with properties {name:thename}
end if
set destination to apath & ":" & thename & ":"
end tell
with timeout of 6000 seconds
tell a
set settings to "JPEG - Original Size"
export theimages using settings to alias destination
end tell
end timeout
end tell
end repeat
end tell
end processAlbums
on processSfolders(flist, fpath)
tell application "Aperture"
repeat with a in flist
set thename to name of a
tell application "Finder"
if not (exists folder thename in alias fpath) then
make new folder at alias fpath with properties {name:thename}
end if
end tell
tell a
set sAlist to every album
set sflist to every subfolder
if sflist is equal to {} then
processAlbums(sAlist, fpath & ":" & thename) of me
else
if sAlist is not equal to {} then
processAlbums(sAlist, fpath & ":" & thename) of me
end if
processSfolders(sflist, fpath & ":" & thename) of me
end if
end tell
end repeat
end tell
end processSfolders
The Bagelturf site welcomes Donations of any size