2012-08-13 40 views
4

我試圖將筆記從Evernote v.3.3.0以HTML格式導出到使用AppleScript的磁盤位置。目前的任務似乎並沒有特別複雜,但我對Evernote相對陌生,對於AppleScript來說是全新的並沒有多大幫助;;)如何使用AppleScript從Evernote導出筆記?

這是我到目前爲止所提出的 - 任何意見都非常感謝!

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.。有任何想法嗎?

非常感謝提前! :)

回答

6

終於勝利了!這個問題與我的腳本沒有任何關係,事實上我從App Store安裝了Evernote。與可從evernote.com下載的版本不同,App Store版本受Mac OS X中的App Sandboxing限制。現在,在安裝非App Store版本後,上述腳本完美運行。

再次感謝您的回答,以及遇到同樣問題的人 - 我希望您的問題也可以通過上述方式解決。

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 
+2

謝謝! :)我在想我可能誤解了我的問題。 當測試文件夾不存在時運行腳本給了我'Evernote有一個錯誤:無法創建輸出目錄.'。如果我先手動創建文件夾,它會抱怨'Evernote有一個錯誤:無法刪除現有的輸出文件。 恐怕錯誤信息並不能讓我更接近解決方案? Evernote爲了讓這個工作起作用,我想要什麼? – 2012-08-14 00:48:26

+0

嘗試編輯後的版本... – adayzdone 2012-08-14 01:25:14

+2

再次感謝您付出的努力 - 非常感謝!該腳本是否可以在您的機器上運行?在我的,它不斷給我'Evernote有一個錯誤:無法刪除現有的輸出文件。我開始相信AppleScript字典中導出動詞的語法對於HTML格式可能不正確或不完整?畢竟 - 作爲ENEX(單個文件)或HTML(每個音符一個文件)導出應該可能需要不同的輸入,對吧? – 2012-08-14 10:39:53

1

認爲這是在3.3的錯誤 - 我已經寫了a fair number of AppleScripts for Evernote(包括那些有工作導出功能)和最近encountered the same types of "permission" errors

當我聯繫Evernote開發者支持時,他們回覆說他們的團隊正在研究這個問題。我將把這個頁面轉發給他們,供他們參考,並希望3.3.1版本將帶來一個修復!

+0

很高興收到你的來信!當然,我知道你的網站 - 這是我發現第一個使用AppleScript進行我的小備份程序的靈感! :)在上面的回覆中,adiayzdone聲稱他的Snow Leopard機器上的工作正常。也許這個問題與山獅有關係?週末愉快! :) – 2012-08-17 16:32:41

+0

似乎我們需要更加耐心 - 根據Mac App Store的說法,3.3.1版本只增加了掃描儀支持 - 沒有修復AppleScript界面​​ - 這一點由我的腳本仍然無法使用正如預期的那樣...... – 2012-09-17 19:53:22

+1

嗯......希望版本5.0能夠解決這個問題,但是(除非我正在做一些嚴重錯誤的事情),事實並非如此。 :( – 2012-11-26 20:00:35

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庫(其可以是非常大的),一個可與{firstNote,secondNote}取代的allNotes出現的兩個。

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 
+1

歡迎來到Stack Overflow!While這可能是一個解決問題的有價值的提示,一個好的答案也可以說明解決方案。請[編輯]提供示例代碼來展示您的意思。或者,請考慮將其寫爲註釋。 – 2017-08-15 13:12:26

相關問題