applescriptdam

Aperture export import script


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.


Solution

  • 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")