IMPORTING
Note: The scripts on this site are provided as is and I am unable provide any technical assistance. Backup all data before using any of the scripts this site provides.
Automating importing images into Aperture can be done in a number of ways. We can either import the images one at a time or as a large chuck or import an entire directory of images (the same as import folder as project).
This example shows how to import images one by one. I'm not entirely sure why you would want to go with this solution, however it may be possible to do something to the individual image or get something from before/after importing the image.
Import
one image at a time.
--ask user for a
directory containing images.
tell
application
"Finder"
set import_dir
to (choose folder
with
prompt "Choose a
folder of images for import")
as alias
set file_list
to list folder
(import_dir)
without invisibles
--get directory
contents as a list and no invisibles
end
tell
tell
application
"Aperture"
activate
tell library
1
set ap_proj
to make new project
with
properties {name:"new_project"}
--create new project
here before the import. feel free to change the name of the
project.
end
tell
--take each item of
the file list, in this case image files, and import one by
one
repeat
with i
from 1
to
the count
of file_list
set this_file
to ((import_dir
as text) & (item i
of file_list))
as alias
import
this_file
by
referencing
into
ap_proj
--import file into
project by reference, refer to the dictionary for other import
options
end
repeat
end
tell
And below is a script that is a bit more polished that imports an entire list of files as once instead of one at a time. You should see an improvement in speed using this script versus the above import script. I threw in additional prompts so you wouldn't have to hard code the name of the project you want to import to and this lets you choose the import method at any time which can come in handy.
Import
list of files at once.
set
proj_name
to ""
set
these_files
to {}
--ask user for a
directory containing images.
tell
application
"Finder"
set import_dir
to (choose folder
with
prompt "Choose a
folder of images for import")
--set file_list to
list folder (import_dir) without invisibles --get directory
contents as list and no invisibles
set file_list
to (entire contents
of folder
import_dir)
as alias list
end
tell
tell
application
"Aperture"
activate
--ask for project
name
display dialog
"Enter name of
project:" default answer
proj_name
buttons
{"OK", "Cancel"} default button
1
set proj_name
to text returned
of
the result
--ask for import
method
display dialog
"Select an import
method" buttons
{"Copy",
"Move", "Reference"} default button
3
set import_meth
to
the button returned
of
the result
--create a new
project, unless it already exists
tell library
1
if
not (exists
project
proj_name)
then
set ap_proj
to make new project
with
properties {name:proj_name}
else
set ap_proj
to project
proj_name
end
if
end
tell
--import entire list
of files either by copying, moving, or referencing into the
project
if import_meth
is "Copy"
then
with
timeout
of 600
seconds
import
file_list
by
copying
into
ap_proj
end
timeout
else
if import_meth
is "Move"
then
with
timeout
of 600
seconds
import
file_list
by
moving
into
ap_proj
end
timeout
else
with
timeout
of 600
seconds
import
file_list
by
referencing
into
ap_proj
end
timeout
end
if
end
tell
Importing a directory as a project is similar to importing a list of files at once. But instead of telling Aperture to import list of files, you tell it to import a directory (not its contents, just the path to the directory).
