Folder Action — Evernote Exporter – Japanese Language

Description

Japanese version of the current “Evernote Dropbox” script. 日本語手順書はこちら

The Code

(*
http://veritrope.com
Folder Action -- Evernote Exporter
Version 1.0
June 7, 2010
Project Status, Latest Updates, and Comments Collected at:
http://veritrope.com/tips/evernote-desktop-folder
=====================================
WITH GREAT THANKS TO SYNKURO FOR THIS TRANSLATION!
=====================================
*)

property theNum : "0"
property EVnotebook : ""
property thename : ""
property theNotes : ""
property theBody : ""
property theURL : ""

on adding folder items to this_folder after receiving added_items
    delay 5
   
    (*MAIN PROGRAM *)
    tell application "Evernote"
        --set successCount to 0
        set defaultTag to "@Evernote"
        display dialog "" & ¬
            "タグを入力(コロンかコンマで分割)" with title "Evernote へ読み込み" default answer defaultTag buttons {"既定のノートブックに作成", "ノートブックを選択", "キャンセル"} default button "既定のノートブックに作成" cancel button ¬
            "キャンセル" with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
        set dialogresult to the result
        set userInput to text returned of dialogresult
        set ButtonSel to button returned of dialogresult
        set theDelims to {":", ","}
        set EVTag to my Tag_List(userInput, theDelims)
       
        if ButtonSel is "ノートブックを選択" then set EVnotebook to my Notebook_List()
       
        repeat with i from 1 to number of items in added_items
            set new_item to item i of added_items
            create note from file new_item notebook EVnotebook tags EVTag
            (*DELETE THE TEMP FILE/FOLDER *)
        end repeat
    end tell
   
    tell application "Finder" to delete added_items
end adding folder items to

(* SUBROUTINES *)
--TAG SELECTION SUBROUTINE
on Tag_List(userInput, theDelims)
    set oldDelims to AppleScript's text item delimiters
    set theList to {userInput}
    repeat with aDelim in theDelims
        set AppleScript's text item delimiters to aDelim
        set newList to {}
        repeat with anItem in theList
            set newList to newList & text items of anItem
        end repeat
        set theList to newList
    end repeat
    return theList
    set AppleScript's text item delimiters to oldDelims
end Tag_List
--EVERNOTE NOTEBOOK SELECTION SUBROUTINE
on Notebook_List()
    tell application "Evernote"
        activate
        set listOfNotebooks to {} (*PREPARE TO GET EVERNOTE'S LIST OF NOTEBOOKS *)
        set EVNotebooks to every notebook (*GET THE NOTEBOOK LIST *)
        repeat with currentNotebook in EVNotebooks
            set currentNotebookName to (the name of currentNotebook)
            copy currentNotebookName to the end of listOfNotebooks
        end repeat
        set Folders_sorted to my simple_sort(listOfNotebooks) (*SORT THE LIST *)
        set SelNotebook to choose from list of Folders_sorted with title "Evernote のノートブックを選択" with prompt ¬
            "現在の Evernote ノートブック" OK button name "OK" cancel button name "新規ノートブック" (*USER SELECTION FROM NOTEBOOK LIST *)
        if (SelNotebook is false) then (*CREATE NEW NOTEBOOK OPTION *)
            set userInput to ¬
                text returned of (display dialog "新規ノートブック名を入力:" default answer "")
            set EVnotebook to userInput
        else
            set EVnotebook to item 1 of SelNotebook
        end if
    end tell
end Notebook_List

--SORT SUBROUTINE
on simple_sort(my_list)
    set the index_list to {}
    set the sorted_list to {}
    repeat (the number of items in my_list) times
        set the low_item to ""
        repeat with i from 1 to (number of items in my_list)
            if i is not in the index_list then
                set this_item to item i of my_list as text
                if the low_item is "" then
                    set the low_item to this_item
                    set the low_item_index to i
                else if this_item comes before the low_item then
                    set the low_item to this_item
                    set the low_item_index to i
                end if
            end if
        end repeat
        set the end of sorted_list to the low_item
        set the end of the index_list to the low_item_index
    end repeat
    return the sorted_list
end simple_sort