1

我在创建一个非常简单的 AppleScript 以从 Evernote 笔记中导出附件时遇到了重大问题。我已经多次使用以下代码,它似乎可以工作,但实际上它会默默地失败,即使事件日志显示正确的响应也是如此。

我听说 Evernote 的最新版本存在严重的 AppleScript 支持问题。如果有人是 Evernote 和 AppleScript 的“专家”,我也会非常感谢对我的脚本进行审查,以确保我不会忘记任何事情。

我正在使用 Mac OS X 10.8.2 和 Evernote 5.0.5 (400805) 的 Mac App Store 版本。

代码:

set ExportPath to "LegatusHD1:Users:me:Downloads:Test"
set theAttachments to {}
set selectedItems to {}

tell application "Evernote"
set selectedItems to selection
repeat with selectedItem in selectedItems
    set theAttachments to (attachments of selectedItem)
    repeat with theAttachment in theAttachments
        set theFilename to (ExportPath & ":" & theAttachment's filename)
        write theAttachment to theFilename
        set theFilename to ""
    end repeat
end repeat
end tell
4

2 回答 2

0

Apple 最近为 AppStore 中的应用程序引入了沙盒。因此,根据您的 OSX 版本,这可能是它静默失败的原因——因为 Evernote 应用程序无法访问其自己的文件夹结构之外的文件系统。您可以尝试将导出路径设置为 Evernote 文件夹中的内容。

于 2013-02-19T03:36:42.580 回答
0

这个问题很老,但我只是在寻找我现在可以提供的答案时绊倒了它:

仅供参考,我正在运行:通过 App Store 安装的 OSX 10.9.1 (Mavericks) 和 Evernote 5.4.4。

我可以确认 Mustafa 是正确的,使用该应用程序的 App Store 版本只能写入沙箱中的文件 (/Users/{username}/Library/Containers/com.evernote.Evernote/)

简短的回答

从 Evernote 网站安装应用程序,或者如果您想使用 App Store 中的应用程序:

使用上述脚本将导出路径更改为沙箱内的内容,例如:

set ExportPath to "Users:{username}:Library:Containers:com.evernote.Evernote:Data:attachment_export"

请记住先创建附件导出文件夹,然后将 {username} 替换为您的用户名

调试注意事项

不幸的是,当您尝试在沙箱之外编写时,applescript 编辑器不会显示任何错误。但是,您可以在 Console 应用程序中查看错误(在 Applications -> Utilities 中找到)。在控制台的搜索框(右上角)中输入“沙盒”,在窗口底部您将看到如下内容:

2014 年 1 月 29 日 10:22:29.426 沙盒 [310]: ([4433]) Evernote(4433) 拒绝文件写入创建 /Users/{用户名}/Desktop/Evernote 快照 20140128 134741.jpg

于 2014-01-29T04:23:15.010 回答