Aperture export import script

262 Views Asked by At

With macOS Catalina dropping support for Aperture, I need to move my library to a different application. Mylio has a great import tool that carries over almost all of the library structure and metadata but loses some of the adjustments. To retain those, I'm trying to write an Apple script that exports all images (with adjustments applied) in my library and reimports them into the same project before deleting the original.

I think I almost have the first part, exporting all images.

tell application "Aperture"
  tell library 1
        set projects to (get every project)
        repeat with i from 1 to count of projects
            tell (item i of projects)
                export its every image version naming folders with folder naming policy ¬
                    "Project Name" using export setting ¬
                    "JPEG - Original Size" to (choose folder with prompt "Choose an export folder")
            end tell
        end repeat
  end tell
end tell

However, when I try to run this script, I keep getting the error

apertureExportImport.applescript:704:712:
execution error: Aperture got an error: Can’t make {project id "1ixjjya6T+Sb3pFmhRK8Fg"} into type project. (-1700)

I guess the problem is with set projects to (get every project) but I can't find any examples online from which to figure out what else to write here.

2

There are 2 best solutions below

12
CJK On BEST ANSWER

I don't use Aperture, so I can only take an educated guess:

From the error message, I can be reasonably sure that project is an AppleScript object, specifically an element that, from your script, I'll assume belongs to a library object. In that case, there will almost certainly be a plural element form named "projects" already defined , which would refer to a collection of (i.e. multiple) elements that are all of type project.

Therefore, the following line:

set projects to (get every project)

is problematic, because you're attempting to redefine a class object that belongs to AppleScript. In fact, projects will be shorthand for every project, so this should already be defined in the way that you want, and simply removing this line completely should be sufficient.

On a separate note, it looks like (from you script) the export command can be passed a collection of objects as its direct parameter, which you’re doing with export its every image.... Assuming this is valid, then it might be able to export all images in all projects at once:

tell application "Aperture" to export every image version in every project of library 1 ¬
    naming folders with folder naming policy "Project Name" using export setting ¬
    "JPEG - Original Size" to (choose folder with prompt "Choose an export folder")
0
Janosh On

I got it working in the end (everything except deleting the original images after exporting and reimporting but that I can simply do manually by flagging or color-coding all images the script will handle).

tell application "Aperture"
  with timeout of 86400 seconds
    activate
    set exportSetting to export setting "JPEG - Original Size"
    set folderPolicy to folder naming policy "Project Name"
    set exportFolder to "/Users/<user>/Desktop"
    -- Alternatively, use
    -- set exportFolder to (choose folder with prompt "Choose an export folder")

    tell library 1
    repeat with proj in projects
      set imageSel to every image version in proj where flagged is true
      export imageSel naming folders with folderPolicy using exportSetting to exportFolder
        set importFolder to exportFolder & "/" & name of proj
        import importFolder by referencing into proj
    end repeat
    end tell
  end timeout
end tell

One important lesson that was hard to learn is that exportSetting and folderPolicy need to be set in the context of the entire library (i.e. at the very start of the script) rather than on a per-project level to avoid the error

execution error: Aperture got an error: Can’t get folder naming policy "Project Name". (-1728)