Export Keynote slides to images with AppleScript

892 views Asked by At

I have Keynote slides and I want automatically export them to images for further uploading to server using AppleScript. I've tried to manage it:

tell application "Keynote"
    set doc to open "full-path-to-.key"
    save doc -- this line didn't help
    export doc to file "full-path-to-folder" as slide images
end tell

This script terminates with

error "Keynote got an error: The document “...” could not be exported as “full-path-to-folder”. Your most recent changes might be lost." number 6

Why?

1

There are 1 answers

0
J. S. On BEST ANSWER

I had a closer look at this exporting documents samples and ran into a problem with referencing a folder I want export my slides to. Then I've found that thing about it with a sample

set thePath to alias "Macintosh HD:Users:yourUserName:Desktop:"

So this one works properly:

tell application "Keynote"
     set doc to open "/absolute/path/to/slides.key"
     export doc to alias "Macintosh HD:Users:myUserName:further:path" as slide images with properties {image format:PNG}
end tell