首页 > 解决方案 > 使用 AppleScript 将 Keynote 幻灯片导出到图像

问题描述

我有 Keynote 幻灯片,我想自动将它们导出为图像,以便使用 AppleScript 进一步上传到服务器。我试图管理它:

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

该脚本以

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

为什么?

标签: applescriptkeynote

解决方案


我仔细查看了此导出文档示例,并在引用我要将幻灯片导出到的文件夹时遇到了问题。然后我用一个样本找到了关于它的东西

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

所以这个工作正常:

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

推荐阅读