IMPORTING
Note: The scripts on this site are provided as is and I am unable to provide any technical assistance. Backup all data before using any script provided by this website.
Automating the importing of 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
Below is a script that imports an entire list of files at once instead of passing one image to Aperture at a time. You should see an improvement in speed using this script versus the import script above.
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
