7

我正在尝试使用 AppleScript 将笔记从 Evernote v.3.3.0 以 HTML 格式导出到磁盘上的某个位置。手头的任务似乎并不特别复杂,但我对 Evernote 相对较新,对 AppleScript 完全陌生并没有多大帮助... ;)

这是我到目前为止的想法 - 非常感谢任何评论!

tell application "Evernote"
    set allmynotes to find notes
    set outputpath to "/Users/{myusername}/Desktop/Test"
    export allmynotes to outputpath format HTML
end tell

据我了解,导出为 HTML 会为每个笔记创建一个文件,这就是为什么我认为我需要指定输出文件夹名称而不是输出文件名的原因。另一个假设是脚本在双击时将使用活动用户的凭据运行。在我的机器上,该用户有足够的权限写入指定的文件夹。

到目前为止的结果是Evernote got an error: Unable to remove existing output file." number 1Evernote got an error: Unable to create output directory.。有任何想法吗?

提前谢谢了!:)

4

5 回答 5

8

终于胜利了!这个问题与我的脚本无关,而与我从 App Store 安装 Evernote 的事实无关。App Store 版本与可从evernote.com 下载的版本不同,受Mac OS X 中的App Sandboxing 限制。现在,安装非App Store 版本后,上述脚本可以完美运行。

再次感谢您的回答,以及那些遇到相同问题的人-我希望您的问题也可以通过上述方式解决。

于 2013-08-07T18:10:36.090 回答
1

Think it's a bug in 3.3 -- I have written a fair number of AppleScripts for Evernote (including ones with working export functions) and have recently encountered the same types of "permission" errors.

When I reached out to Evernote Developer Support, they replied that their team is currently looking at the issue. I will forward this page to them for their reference and, hopefully, version 3.3.1 will bring a fix!

于 2012-08-16T13:55:23.880 回答
0

你很接近:

set outputpath to (path to desktop as text) & "Evernote Test"
do shell script "mkdir -p " & quoted form of POSIX path of outputpath

tell application "Evernote"
    set allmynotes to find notes
    export allmynotes to outputpath format HTML
end tell
于 2012-08-13T22:41:05.890 回答
0

在 Evernote 5.2.1 (Mac OS X 10.8.4) 上,我可以验证adayzdone的答案是否可靠,无论输出文件夹是否已经存在。如果给定文件夹确实存在,Evernote 会将其移至回收站并创建一个新文件夹。

从最初的问题中,我收集了关于如何处理边缘情况的不确定性(例如已经存在的早期导出文件夹)。这是使用对话框处理这种情况的代码。

set folderName to "Latest Evernote HTML Export"
set exportFolder to (path to documents folder as text) & folderName as text
tell application "Finder"
    if exportFolder exists then
        set answer to the button returned of (display dialog "This will overwrite the previous Evernote HTML export" buttons {"Stop", "Overwrite"} default button 1)
        if answer is equal to "Stop" then
            error number -128 -- end script with error "User Cancelled"
        end if
    end if
end tell

tell application "Evernote"
    set allNotes to find notes
    export allNotes to exportFolder format HTML
end tell

测试提示:为避免导出完整的 Evernote 库(可能非常大),可以将出现的两次 allNotes替换为{firstNote, secondNote}

于 2013-08-05T19:52:00.880 回答
0
set folderName to "Latest Evernote HTML Export"
set exportFolder to (path to documents folder as text) & folderName as text
tell application "Finder"
    if exportFolder exists then
        set answer to the button returned of (display dialog "This will overwrite the previous Evernote HTML export" buttons {"Stop", "Overwrite"} default button 1)
        if answer is equal to "Stop" then
            error number -128 -- end script with error "User Cancelled"
        end if
    end if
end tell

tell application "Evernote"
    set allNotes to find notes
    export allNotes to exportFolder format HTML
end tell
于 2017-08-15T12:52:52.487 回答