Hey guys, still a newbie, but I am learning, I swear!
I found this awesome folder action script for Evernote, and it works great. I use it all the time.
Now I was trying to figure out how to adjust it for my automator workflow that I am working on.
What I want it to do is NOT prompt me to choose the notebook or tags. All I want it to do when I add a file to the folder is to automatically add it to one of my notebooks (“Changes Log”). For instance if I drop a text file into the folder, then what I want it to do is automatically file it in Evernote in my notebook called “Changes Log”. That’s all.
How do I got about doing this?
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 "" & ¬
"Enter Your Tags (Separated By Colons or Commas)" with title "Evernote Import" default answer defaultTag buttons {"Create in Default Notebook", "Select Notebook from List", "Cancel"} default button "Create in Default Notebook" cancel button ¬
"Cancel" 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 "Select Notebook from List" 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 "Select Evernote Notebook" with prompt ¬
"Current Evernote Notebooks" OK button name "OK" cancel button name "New Notebook" (*USER SELECTION FROM NOTEBOOK LIST *)
if (SelNotebook is false) then (*CREATE NEW NOTEBOOK OPTION *)
set userInput to ¬
text returned of (display dialog "Enter New Notebook Name:" 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