Created
January 28, 2014 05:56
-
-
Save rashita/8662890 to your computer and use it in GitHub Desktop.
選択したノートを取り込むか、Everntoeを「ノートブック、タグ、キーワード」で検索し検索結果を、OmniOutlinerに取り込む。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on getNotebookNames() -- ノートブックリストを取得 | |
tell application "Evernote" | |
set nameList to name of notebooks | |
end tell | |
return sortList(nameList) | |
end getNotebookNames | |
on getTagNames() -- タグリストを取得 | |
tell application "Evernote" | |
set nameList to name of tags | |
end tell | |
return sortList(nameList) | |
end getTagNames | |
on sortList(aList) --アルファベット順にリストを整形 | |
set oldDelimiters to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to {ASCII character 10} | |
set str to aList as string | |
set str to do shell script "echo " & quoted form of str & " | sort -f" | |
set sortedList to paragraphs of str | |
set AppleScript's text item delimiters to oldDelimiters | |
return sortedList | |
end sortList | |
--起動時にモード(選択か検索か)を選んでもらう | |
display dialog "選択したノートを取り込ますか?" buttons {"取り込む", "検索する"} default button 1 | |
set button_returned to button returned of result | |
if button_returned is "取り込む" then | |
tell application "Evernote" | |
repeat with var_note in (get selection) -- 選択しているノート | |
set linename to (get title of var_note) | |
set linkname to (get note link of var_note) | |
my addrow(linename, linkname) | |
end repeat | |
end tell | |
return | |
else | |
end if | |
set notebookNames to getNotebookNames() | |
set firstNotebookName to item 1 of notebookNames | |
set selectedNotebooks to choose from list notebookNames with prompt "ノートブックを選択して下さい" default items firstNotebookName -- with multiple selections allowed 複数ノートブックの選択を可能にする | |
if selectedNotebooks = false then set sarchnotebook to "" | |
display dialog "タグを選択しますか?" buttons {"タグを選択する", "キーワードの入力へ"} default button 1 | |
set button_returned to button returned of result | |
if button_returned is "タグを選択する" then | |
set TagNames to getTagNames() | |
set selectedTags to choose from list TagNames with prompt "タグを選択して下さい" | |
if selectedTags = false then set selectedTags to "" | |
else | |
set selectedTags to "" | |
end if | |
set sarchtext to text returned of (display dialog "検索ワードをどうぞ!" default answer "") | |
tell application "Evernote" | |
-- 別処理できそう。 | |
if selectedTags is "" then | |
set sarchtag to "" | |
else | |
set sarchtag to "tag:\"" & selectedTags & "\" " | |
end if | |
if selectedNotebooks is "" then | |
set sarchnotebook to "" | |
else | |
set sarchnotebook to "notebook:\"" & selectedNotebooks & "\" " | |
end if | |
set sarchword to sarchnotebook & sarchtag & sarchtext | |
set sarchnote to find notes sarchword | |
if not (sarchnote = {}) then | |
repeat with var_note in sarchnote | |
set linename to (get title of var_note) | |
set linkname to (get note link of var_note) | |
my addrow(linename, linkname) | |
end repeat | |
else | |
set dialogtext to "ノートはありません" | |
end if | |
end tell | |
on addrow(notename, notelink) | |
tell application "OmniOutliner" | |
set newtopic to (make with properties {topic:notename} new row at end of document 1) | |
set note of newtopic to notelink | |
end tell | |
end addrow | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment