NetNewsWire to Evernote — Single Headline or Tab Export Applescript

Use a Mac and want to file away the things you’re reading in NetNewsWire quickly?

Description

NetNewsWire is the heart of my browsing experience these days. I’m spending as much time reading feeds as I do browsing the web and it’s important for me to be able to keep track of the things I am reading and want to reference later.

Once Evernote enabled Applescript support, I realized that I could file away the feed items that were useful to me. Evernote is a real life-saver: It’s accessible from practically every type of computing platform short of an abacus. If you have a Mac, your notes become part of your Spotlight index. Fewer ideas and articles get lost. For someone like me who is working on a dozen different projects simultaneously, this is a real “quality of life” improvement — not just another piece of tech that leaves you less organized and your mind more cluttered.

Features

nnw-single1

I have added tag support, which lets you tag items on the way into Evernote. The script will also retrieve an alphabetized list of your current Evernote Notebooks and allow you to select which notebook to archive the feed items into. Want to make a new notebook? No problem — the script has a “Create New Notebook” button which will let you do that on the fly!

Automatic Growl detection has also been enabled which will save you a trip to the Script Editor to enable/disable it.

Current Limitations and Open Issues

  1. I never figured out how to successfully write the NetNewsWire item’s URL into Evernote’s “source URL” value without using the “create note from url” command. I chose to use the “create note from html” approach because the results were sometimes more visually appealing once the note arrived into Evernote. I am hopeful that this will eventually be possible; WORKING PROPERLY IN VERSION 1.01!
  2. There is some Growl weirdness when using the “iPhone mini” skin;
  3. Errors that will undoubtedly arise when you do something that I didn’t think of or test for! 😉

How to Install and Use

Just drop it into the NetNewsWire Script Folder!

FastScript link and support

Do yourself a favor and download and install FastScripts from Red Sweater. Triggering the script from the keyboard really supercharges the process — you’ll watch your news items practically fly into Evernote with a few keystrokes! Here’s how you set it up:

  • Copy script or an Alias to ~/Library/Scripts/Applications/NetNewsWire
  • Set up your keyboard shortcut

For my workflow, I am using ⌘ E (as in Evernote) for the quick single post script shortcut and ⌘ SHIFT E for the batch script.

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!

(*
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

DOWNLOAD THE SCRIPT FILE

Did this script help you out? Feel free to make a donation!


Found a bug in the script?

Click Here To Submit Your Bug Report!

Interested in what other scripts are available for Evernote? Click here to see the latest list!

40 Responses to “NetNewsWire to Evernote — Single Headline or Tab Export Applescript”

  1. Ryan October 24, 2008 at 12:43 pm #

    Sweet. I’ve been waiting for this…

  2. Manuel November 25, 2008 at 8:50 pm #

    Thank you very much. But can you reduce the number of popups?

    • Justin November 26, 2008 at 2:30 am #

      Which of the menu screens are you not finding useful?

  3. patte January 25, 2009 at 8:16 pm #

    Brilliant. Thanks a lot for sharing this one.

  4. Pearl March 17, 2009 at 12:38 am #

    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.

    • Justin March 17, 2009 at 1:03 am #

      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

      • J July 9, 2010 at 9:38 am #

        You can also set a keyboard shortcut for NetNewsWire without Fastscripts, by simply adding your shortcut to System Preferences>Keyboard>Keyboard Shortcuts>Application Shortcuts… Love this script btw!

  5. Julian April 17, 2009 at 12:09 pm #

    Great way to enhance Evernote – Thanks

  6. Eric May 11, 2009 at 5:05 pm #

    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.

    • Justin May 11, 2009 at 7:28 pm #

      DONE!

      Try it out and let me know what you think,
      Justin

  7. Jo July 25, 2009 at 5:34 am #

    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

    • Justin July 25, 2009 at 10:07 am #

      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!

      • joren August 9, 2009 at 7:18 am #

        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.

        • Justin August 9, 2009 at 11:18 am #

          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?

          • joren August 9, 2009 at 1:32 pm #

            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.

  8. Justin August 9, 2009 at 1:58 pm #

    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. 😀

    • Joren August 9, 2009 at 6:09 pm #

      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.

      • Joren August 9, 2009 at 6:10 pm #

        I’m using the latest version of the script found on your site. I also checked my other notebooks 🙂

  9. Justin August 9, 2009 at 9:36 pm #

    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!

    • joren August 10, 2009 at 3:03 pm #

      Justin, Your updated script appears to work just fine! Many thanks.

  10. Peer November 25, 2009 at 10:44 am #

    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.

    • Justin November 25, 2009 at 11:10 am #

      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!

  11. Mike January 14, 2010 at 3:01 am #

    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.

    • Justin January 15, 2010 at 4:20 am #

      Thanks Mike!

  12. kemumaki_kemuzo (Kimihiro OHKUBO) March 19, 2010 at 4:16 pm #

    Twitter Comment


    RSSリーダとしてNetnewswire を使っている人にこれは便利。NNW+Evwenote [link to post]

    Posted using Chat Catcher