(* http://veritrope.com Batch Send -- NNW to Evernote Version 1.0 October 14th, 2008 Project Status, Latest Updates, and Comments Collected at: http://veritrope.com/tips/netnewswire-to-evernote-batch-send-applescript This script is primarily an adaptation of Daniel N. Byler's excellent DEVONthink script. http://bylr.net/3/2008/06/archive-newsfeeds-in-devonthink-pro-via-netnewswire/                 Some other choices inspired by the following scripts/authors:         -- NetNewsWire To Pukka and Yojimbo script         -- Jan Erik Mostrom's script         -- David Nunez         -- Ernie Soffronoff              -- MANY, MANY OTHERS! Installation: Just drop it into the NetNewsWire Script Folder!                  FastScripts Installation (Optional, but recommended): --Download and Install FastScripts from http://www.red-sweater.com/fastscripts/index.html --Copy script or an Alias to ~/Library/Scripts/Applications/NetNewsWire --Set up your keyboard shortcut *) property showAlert : true --if true, will display success/failure alerts property maxPause : 1 property criteriaList : {"All Items in Folder", "Flagged Items Folder", "Unread Items in Folder"} ¬         -- "Read Items in Folder" CURRENTLY NOT WORKING property successCount : 0 property selectCriterion : "" property every_headline : "" property abortScript : false property useGrowl : "" property growlAppName : "NetNewsWire to Evernote" property allNotifications : {"General", "Error"} property enabledNotifications : {"General", "Error"} property iconApplication : "Evernote.app" property NNWTag : "" property EVnotebook : "" property NNWBody : "" property postaction : "" -- CHECK FOR GROWL tell application "System Events"         set processnames to name of every process end tell if "GrowlHelperApp" is in processnames then         set useGrowl to true         tell application "GrowlHelperApp"                 register as application growlAppName all notifications allNotifications ¬                         default notifications enabledNotifications icon of application iconApplication         end tell end if (*MAIN PROGRAM *) my main() on main()         set oldDelims to AppleScript's text item delimiters         tell application "NetNewsWire"                 activate                 my chooseArchiveCriterion()                 if selectCriterion is "false" then                         return                 end if                 my selectMatchingArticles(selectCriterion)                 if (count of every_headline) is 0 then                         set abortScript to true                         display dialog "No valid content selected." buttons {"OK"} default button 1                         return                 end if                 set postaction to my choosePostAction(selectCriterion)                 if postaction is "false" then                         return                 end if                 activate                 my warnArchiveTotal(every_headline)                 set defaultTag to (display name of selectedSubscription) --DEFAULT TAG IS SELECTED SUBSCRIPTION NAME/FOLDER                 set userInput to ¬                         text returned of (display dialog "Enter Tags, separated by colons or commas:" & return & return & ¬                         "NOTE: The Default Tag is selected Subscription Name or its Parent Folder." default answer defaultTag)                 set theDelims to {":", ","}                 set t to my Tag_List(userInput, theDelims)                 if t is "false" then                         return                 end if                 set n to my Notebook_List()                 if n is "false" then                         return                 end if                 activate                 my alertStart(every_headline, t, n)                 repeat with i in every_headline                         my subArchiveMain(i, t, n)                         my subPostAction(i, postaction)                         my pauseScript()                 end repeat                 activate                 my alertFinish(every_headline, n, successCount)                 set successCount to 0         end tell end main (* SUBROUTINES *) on chooseArchiveCriterion()         tell application "NetNewsWire"                 activate                 set selectCriterion to ¬                         (choose from list criteriaList default items "All" with title "Archive which items?") as string                 return         end tell end chooseArchiveCriterion on selectMatchingArticles(selectCriterion)         tell application "NetNewsWire"                 if selectCriterion is "All Items in Folder" then                         set every_headline to every headline of selectedSubscription                 else if selectCriterion is "Flagged Items Folder" then                         set every_headline to every headline of (first subscription whose display name is "Flagged Items")                 else if selectCriterion is "Unread Items in Folder" then                         set every_headline to every headline of selectedSubscription whose isRead is false                         (* CURRENTLY NOT WORKING PROPERLY                 else if selectCriterion is "Read Items in Folder" then                         set every_headline to every headline of selectedSubscription whose isRead is true *)                 end if                 return every_headline         end tell end selectMatchingArticles on choosePostAction(selectCriterion)         tell application "NetNewsWire"                 if selectCriterion is "All Items in Folder" then                         set postaction to (choose from list {"Unflag", "Mark read", "None"} ¬                                 default items "None" with title "Post-archive action?") as string                 else if selectCriterion is "Flagged Items Folder" then                         set postaction to (choose from list {"Unflag", "None"} ¬                                 default items "None" with title "Post-archive action?") as string                 else if selectCriterion is "Unread Items in Folder" then                         set postaction to (choose from list {"Mark read", "None"} ¬                                 default items "None" with title "Post-archive action?") as string                         (* else if selectCriterion is "Read Items in Folder" then                         set postaction to (choose from list {"Unflag", "None"} ¬                                 default items "None" with title "Post-archive action?") as string¬                                 CURRENTLY NOT WORKING *)                 end if         end tell         return postaction end choosePostAction on warnArchiveTotal(every_headline)         tell application "NetNewsWire"                 activate                 set result to display dialog "You're trying to archive " & return & (count of every_headline) & ¬                         " articles. Continue?" buttons {"Cancel", "Continue"} default button 2 with icon caution giving up after 60                 if button returned of result is equal to "Cancel" then                         set abortScript to true                         return                 end if         end tell end warnArchiveTotal on alertStart(every_headline, t, n)         activate         if (count of every_headline) is 0 then                 set alertName to "Error"                 set alertTitle to "Script failure"                 set alertText to "No valid content to archive"                 my notify(alertName, alertTitle, alertText)                 return         else                 activate                 set alertName to "General"                 set alertTitle to "Export to Evernote"                 set alertText to "Attempting to archive " & (count of every_headline) & " headlines into " & n                 my notify(alertName, alertTitle, alertText)                 return         end if end alertStart on alertFinish(every_headline, n, successCount)         activate         if successCount is 0 then                 set alertName to "Error"                 set alertTitle to "Script failure"                 set alertText to "Error: no headlines archived"                 my notify(alertName, alertTitle, alertText)                 return         else                 set alertName to "General"                 set alertTitle to "Export to Evernote Successful!"                 set alertText to ¬                         (successCount & " of " & (count of every_headline) & " headlines archived to " & EVnotebook) as string                 my notify(alertName, alertTitle, alertText)                 return         end if end alertFinish on notify(alertName, alertTitle, alertText)         if showAlert is false then                 return         else if useGrowl is true then                 tell application "GrowlHelperApp"                         notify with name alertName title alertTitle application name "NetNewsWire to Evernote" description alertText                 end tell         else                 display dialog alertText with icon 1         end if end notify on subArchiveMain(i, t, n)         tell application "NetNewsWire"                 set NNWTitle to title of i                 set EVtag to t                 if exists description of i then                         set NNWBody to description of i                 end if                 tell application "Evernote" -- CREATE THE NOTE FROM HEADLINE                         activate                         create note with html NNWBody title NNWTitle tags EVtag notebook EVnotebook                         set successCount to successCount + 1                 end tell         end tell         end subArchiveMain on subPostAction(i, postaction)         tell application "NetNewsWire"                 if postaction is "Unflag" then                         set isFlagged of i to false                 else if postaction is "Mark read" then                         set isRead of i to true                 end if         end tell end subPostAction on pauseScript()         set rn to (random number (maxPause)) as text         delay rn end pauseScript --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                                 (*SORT THE LIST *)                 set Folders_sorted to my simple_sort(listOfNotebooks)                                 (*USER SELECTION FROM NOTEBOOK 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"                 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