Save Safari Tabs to Evernote

Description

This AppleScript saves a list of all the open tabs in your (frontmost) Safari window to a new item in Evernote – Perfect for keeping track of webpages to return to later instead of keeping a billion tabs open all the time!

Alfred Users

I've rolled this script into a ready-to-go workflow for you – click here to download it. I've given it a default keyword of "ste" (as in "Safari Tabs to Evernote") to make it work with some of my other workflows which send Chrome Tabs to OmniFocus and which send Safari Tabs to OmniFocus.

Launchbar 6 Users

I've assembled this script into a pre-packaged Action for you as well! Consider this "Experimental" as I'm new to LB6 but, if you want to try it out, click here to download it. Enjoy!

The Code

(*
◸ Veritrope.com
Safari Tab List to Evernote Exporter
Version 1.1
June 15, 2014

// UPDATE NOTICES
    ** Follow @Veritrope on Twitter, Facebook, Google Plus, and ADN for Update Notices! **

// SUPPORT VERITROPE!
    If this AppleScript was useful to you, please take a second to show your love here:
    http://veritrope.com/support
   
// SCRIPT INFORMATION AND UPDATE PAGE:
    http://veritrope.com/code/export-all-safari-tabs-to-evernote

// TERMS OF USE:
    This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

// CHANGELOG:
    1.10    NOTIFICATION CENTER, BETTER COMMENTS
    1.00    INITIAL RELEASE

*)


--RESET VALUES
set urlList to {}
set currentTab to 0

--SET DATE STAMP
set the dateStamp to ((the current date) as string)
set NoteTitle to "URL List from Safari Tabs on " & the dateStamp

--PROCESS TABS OF FRONTMOST SAFARI WINDOW
tell application "Safari"
    activate
    set safariWindow to the front window
    set successCount to 0
    set tabCount to (count of (tabs of safariWindow))
   
    repeat with w in safariWindow
        --GET TAB INFORMATION  
        try
            repeat with t in (tabs of w)
                set TabTitle to (name of t)
                set TabURL to (URL of t)
                set TabInfo to ("" & TabTitle & return & TabURL & return & return)
                --COPY TAB INFO TO END OF LIST 
                copy TabInfo to the end of urlList
               
                --INCREMENT SUCCESS COUNT
                set successCount to (successCount + 1)
               
            end repeat
        end try
    end repeat
end tell

--CONVERT LIST TO TEXT
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set url_list to urlList as text
set AppleScript's text item delimiters to old_delim

--MAKE ITEM IN EVERNOTE
tell application "Evernote"
    set EVNote to (create note with text url_list title NoteTitle)
end tell

--NOTIFY RESULTS
my notification_Center(successCount, tabCount)

(*
======================================
// NOTIFICATION SUBROUTINE
======================================
*)


--NOTIFICATION CENTER
on notification_Center(successCount, itemNum)
    set Plural_Test to (successCount) as number
   
    if Plural_Test is -1 then
        display notification "No Tabs Exported!" with title "Send Safari Tabs to Evernote" subtitle "◸ Veritrope.com"
       
    else if Plural_Test is 0 then
        display notification "No Tabs Exported!" with title "Send Safari Tabs to Evernote" subtitle "◸ Veritrope.com"
       
    else if Plural_Test is equal to 1 then
        display notification "Successfully Exported " & itemNum & ¬
            " Tab to Evernote" with title "Send Safari Tabs to Evernote" subtitle "◸ Veritrope.com"
       
    else if Plural_Test is greater than 1 then
        display notification "Successfully Exported " & itemNum & ¬
            " Tabs to Evernote" with title "Send Safari Tabs to Evernote" subtitle "◸ Veritrope.com"
    end if
   
    set itemNum to "0"
    delay 1
end notification_Center

5 Responses to “Save Safari Tabs to Evernote”

  1. steve June 14, 2011 at 6:54 pm #

    Nice! I was going to write this but you saved me an hour!

  2. Laura June 29, 2012 at 10:03 am #

    Thanks for this script! Exactly what I was looking for, and it ran so quickly and easily! It’s now saved as an app for future use.

  3. George June 18, 2014 at 4:40 pm #

    Awesome, thank you!

    FYI the Notification Center stuff is not working for me under 10.8. I chopped it out and the script now compiles and runs fine.

  4. Brendon June 19, 2014 at 3:38 am #

    Thank you!!

    Is there a way to also set the notebook to which it sends…?

    • Justin Lancy June 19, 2014 at 5:17 am #

      Absolutely – and that’s one of the great things about AppleScript: You can customize it to fit your exact needs. If you look at some of the other Evernote AppleScripts here, you’ll see example of code which sets notebooks, tags, etc. With a little trial-and-error, you should be able to whip up your own version pretty quickly!