13
Oct
NetNewsWire to Evernote — Single Headline or Tab Export Applescript
Tags: API, Apple, Applescript, Evernote, NetNewsWire, tutorial
Change Log:
- 1.20 (August 9, 2009) WORK-AROUND FOR MISSING (DESCRIPTION OF SELECTEDHEADLINE) ELEMENT
- 1.10 (May 11, 2009) STREAMLINING (DEFAULT NOTEBOOK OPTION, CODE CONSOLIDATION) AND VARIOUS COSMETIC IMPROVEMENTS
- 1.01 (October 27, 2008) ADDED SOURCE URL TO NOTES
- 1.00 (October 14, 2008) INITIAL RELEASE OF SCRIPT
Okay all you Applescript Ninjas — here’s the code… Dive in, check it out, and tell me how to make it better in the comment thread below!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | (* http://veritrope.com Single Headline or Tab -- NNW to Evernote Version 1.2 August 09, 2009 Project Status, Latest Updates, and Comments Collected at: http://veritrope.com/tips/netnewswire-to-evernote-single-headline-or-tab-export-applescript Some choices inspired by the following scripts/authors: -- Ernie Soffronoff -- Daniel N. Byler's DEVONthink script -- NetNewsWire To Pukka and Yojimbo -- Jan Erik Mostrom's script -- David Nunez scripts -- 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 CHANGELOG: 1.20 WORK-AROUND FOR MISSING (DESCRIPTION OF SELECTEDHEADLINE) ELEMENT 1.10 STREAMLINING (DEFAULT NOTEBOOK OPTION, CODE CONSOLIDATION) AND VARIOUS COSMETIC IMPROVEMENTS 1.01 ADDED "SOURCE URL" FUNCTIONALITY 1.00 INITIAL RELEASE *) property NNWTitle : "" property NNWTag : "" property NNWBody : "" property EVnotebook : "" property selHeadline : "" (* CHECK FOR GROWL *) tell application "System Events" set processnames to name of every process end tell if "GrowlHelperApp" is in processnames then tell application "GrowlHelperApp" set the allNotificationsList to {"Success Notification", "Failure Notification"} set the enabledNotificationsList to {"Success Notification", "Failure Notification"} register as application ¬ "NetNewsWire to Evernote" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Evernote" end tell end if (*MAIN PROGRAM *) tell application "NetNewsWire" activate try --IS IT A TAB OR A HEADLINE? if (index of selected tab is not 0) then --IT'S A TAB! set urlsList to URLs of tabs set ixCurrentTab to index of selected tab set titleList to titles of tabs my TagandBag(EVnotebook) tell application "Evernote" -- CREATE THE NOTE FROM TAB try if EVnotebook is not "" then create note from url (item (ixCurrentTab + 1) of urlsList) ¬ title (item (ixCurrentTab + 1) of titleList) ¬ tags NNWTag ¬ notebook EVnotebook else create note from url (item (ixCurrentTab + 1) of urlsList) ¬ title (item (ixCurrentTab + 1) of titleList) ¬ tags NNWTag end if end try end tell if "GrowlHelperApp" is in processnames then -- GROWL SUCCESS tell application "GrowlHelperApp" notify with name ¬ "Success Notification" title ¬ "Import Success" description ¬ "Successfully exported \"" & (item (ixCurrentTab + 1) of titleList) & ¬ "\" to Evernote" application name "NetNewsWire to Evernote" end tell end if else if exists selectedHeadline then --IT'S A HEADLINE! set selHeadline to selectedHeadline set NNWURL to (URL of selectedHeadline) set NNWTitle to (title of selectedHeadline) try -- HACK FOR MISSING BODY TEXT IN SOME ITEMS! if (description of selectedHeadline) exists then set NNWBody to (description of selectedHeadline) else set NNWBody to (summary of selectedHeadline) end if end try my TagandBag(EVnotebook) tell application "Evernote" -- CREATE THE NOTE FROM HEADLINE try if EVnotebook is not "" then set n to create note with html NNWBody title NNWTitle notebook EVnotebook tags NNWTag set source URL of n to NNWURL else set n to create note with html NNWBody title NNWTitle tags NNWTag set source URL of n to NNWURL end if end try end tell if "GrowlHelperApp" is in processnames then tell application "GrowlHelperApp" -- GROWL SUCCESS notify with name ¬ "Success Notification" title ¬ "Import Success" description "Successfully exported \"" & NNWTitle & ¬ "\" to Evernote" application name "NetNewsWire to Evernote" end tell end if else if "GrowlHelperApp" is in processnames then tell application "GrowlHelperApp" -- GROWL FAILURE FOR NO SELECTION notify with name ¬ "Failure Notification" title ¬ "Import Failure" description ¬ "No headline or tab selected!" application name "NetNewsWire to Evernote" end tell else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR NO SELECTION display dialog "No headline or tab selected!" with icon 0 end if end if (* ERROR HANDLING *) on error errText number errNum if "GrowlHelperApp" is in processnames then tell application "GrowlHelperApp" -- GROWL FAILURE FOR ERROR notify with name ¬ "Failure Notification" title ¬ "Import Failure" description "Failed to export " & return & NNWTitle & ¬ "\" due to the following error: " & return & errText ¬ application name "NetNewsWire to Evernote" end tell else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR ERROR display dialog "Item Failed to Import: " & errNum & return & errText with icon 0 end if end try end tell tell application "NetNewsWire" activate end tell (* SUBROUTINES *) --"TAGGING AND BAGGING" SUBROUTINE on TagandBag(EVnotebook) tell application "NetNewsWire" set defaultTag to (display name of selectedSubscription) --DEFAULT TAG IS SELECTED SUBSCRIPTION NAME/FOLDER display dialog "" & ¬ "NOTE: Default Tag is the highlighted subscription folder." with title "Enter Your Tags (separated by colons or commas)" 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 tagText to text returned of dialogresult set ButtonSel to button returned of dialogresult set theDelims to {":", ","} set NNWTag to my Tag_List(tagText, theDelims) if ButtonSel is "Select Notebook from List" then set EVnotebook to my Notebook_List() end tell end TagandBag --TAG SELECTION SUBROUTINE on Tag_List(tagText, theDelims) set oldDelims to AppleScript's text item delimiters set theList to {tagText} 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 |
Did this script help you out? Feel free to make a donation!
Interested in what other scripts are available for Evernote? Click here to see the latest list!
NetNewsWire to Evernote — Single Headline or Tab Export ApplescriptPages: 1 2


23 Responses to “NetNewsWire to Evernote — Single Headline or Tab Export Applescript”
Sweet. I’ve been waiting for this…
Thank you very much. But can you reduce the number of popups?
Which of the menu screens are you not finding useful?
Brilliant. Thanks a lot for sharing this one.
How do you enable this without installing fastscripts? I have installed it already and tested it using Applescript, but I wonder how you can activate it through NNW. Thanks. Brilliant, btw.
Hi Pearl,
If you’ve already moved the scripts into NetNewsWire’s script folder, then it should be available from the pull-down menu.
If you aren’t sure if the scripts are in the right place:
1.) Make NetNewsWire the active application by clicking anywhere in the NetNewsWire window. If it’s the active application, you’ll see the words “NetNewsWire” to the right of the Apple icon in the top-left corner of your screen;
2.) Select the script icon from the menu (it’s the symbol between “Window” and “Help”;
3.) You’ll see a drop-down list of all the scripts currently in NetNewsWire’s script folder. If the NNW-to-Evernote scripts aren’t listed, then select “Open Scripts Folder” from the menu and a Finder window will open for the Script folder;
4.) Just drag-and-drop the AppleScript files into that Finder window and the scripts will be available from the Script list!
Hope that this helps!
Justin
Great way to enhance Evernote – Thanks
This works great, thanks! It would be great of the second pop-up (notebook) would be optional so that notes are always put in the default notebook.
DONE!
Try it out and let me know what you think,
Justin
Thanks a lot for this, it’s really useful. I was wondering whether it would be possible to extend it to automatically move items from a particular folder (and then delete them from the folder). I have very little idea about Apple Script, so have no idea whether this is possible, but it would be amazing for my needs. I use Netnewswire on the iphone and use the ‘add to clippings’ feature on the phone for articles I want to come back to. What would be great would be if they automatically got transferred to Evernote. I suppose this could be done by running a ‘Archive items in the Clippings folder’ daily, or something? Any suggestions very much appreciated!
Jo
Hi Jo,
It’s definitely possible to run an AppleScript on a schedule and, with a few modifications to the “batch send” NetNewsWire to Evernote script, you could do exactly what you are talking about. If you’re interested, let me know and we can discuss a customized script for your needs.
For someone that is just getting started with AppleScript/Scripting and wants to run a “daily script”, it would probably make more sense to download an application that does this for you (or serves as a “front end” to the OS X “cron” service).
Here are a few:
Cronnix
Script Timer
Macaroni
That said — you may want to wait. The mobile version of Evernote allows other iPhone apps to ‘Send to Evernote”. Right now, the only one that I know is currently working is the AP News app….but the Evernote guys have been hinting that there are several more apps with this feature on the way.
Personally, I would leave a message on the NNW iPhone Forum asking about adding in a “Send to Evernote” button and see what Brent says… I know he’s working on a new version now.
Hope this helps!
Hi, it appears that the Single-NNW-Evernote script no longer works properly with the latest beta version of NNW. The pop-up appears, followed by a Growl notification that the item has been imported but I the item does not show up in Evernote.
It’s still working on my installation! Anyone else having trouble?
A few questions for anyone who is:
Are you running NNW 3.2b14?
Are you having trouble with exporting headlines, tabs, or both?
Have you tried uninstalling/reinstalling the script?
Hi. Thanks for your prompt reply.
I’m running the latest beta. Not sure whether I’m exporting headlines or tabs (in evernote I see the full contents which is available in the preview pane). I did a full uninstall (including the support folders) and re-installed NNW. Still the same problem.
It’s strange that I get a growl notification that the note was successfully imported.
BTW, I’m experiencing this on 2 machines. I worked fine at first but it suddenly stopped working. Weird.
Totally weird!
Okay, first things first…..
This is a Headline:

and this is a Tab:

Does your problem happen on both types?
You are using Script Version 1.1?
Have you verified that you are looking in the correct notebook? I know that may seem like a silly question, but there was an occasion where I thought *my* notes weren’t showing up… only to realize that I had changed my default notebook and was looking in the wrong place.
Ok, I ran some tests. I’m able to export a tab (I never use this since it basically exports the whole web page (in browsing mode) for that particular item, right?). I noticed that the evernote icon in my dock doesn’t bounce any more like it used to when I exported an item. I don’t know why.
Here’s the strange thing I found out. The export function (for headlines as I always use) works for certain RSS feeds but does not work for other feeds. For example, I’m able to export feeds from “David Allen Company” (again, evernote icon does not bounce) but I’m not able to export feeds from “lifehacker”.
Also, for David Allen Company I’m able to create new tags but this does not work for lifehacker.
I’m using the latest version of the script found on your site. I also checked my other notebooks
Joren,
Your tests and specifics were invaluable in quickly getting to the bottom of what was happening…. Many Thanks!
When I looked at the Lifehacker item in my debugger (as well as another Gawker Media RSS feed), I saw that the AppleScript element in NNW called (description of selectedHeadline) was empty. In AppleScript terms, this is supposed to be the “Body” of the item and the fact that it was blank is pretty perplexing.
I quickly wrote an addition to the script that creates the Evernote item with the NNW item’s “summary” data if the description data is blank. Hope that this is at least a decent work-around until we get to the bottom of things! I am going to send Brent at NetNewsWire a “bug report” in case this is related to the beta code….although it could be just the way Gawker Media formats its RSS feeds.
Download the updated script and let me know if it works for you!
Justin, Your updated script appears to work just fine! Many thanks.
Excellent work. But you say that the dialog boxes are optional? How do I turn them off? I would like to run the script without any further input.
Hi Peer,
When we were talking about “optional dialog boxes” in the thread above, it was to say that the notebook selection portion has now been streamlined into an optional feature.
If you want the script to put items into your default Evernote notebook without any tagging, you could edit out the dialog box portions of the script. If that’s not something you feel comfortable doing, you can commission a custom version from me and I’ll tailor it to your specifications!
Just wanted to say thanks for this. I stopped using Evernote for a while but since switching to OS X I’ve given it another look. Great script you have here, it makes NNW and Evernote a pretty useful combo.
Thanks Mike!
Tweetbacks
Twitter Comment
Great! RT @Veritrope: Single Item NetNewsWire to Evernote AppleScript Updated: [link to post] #NNW #Evernote #AppleScript #NetNewsWire
– Posted using Chat Catcher
Trackbacks/Pingbacks