Delicious Bookmark Importer for Evernote

Description

UPDATE -- March 29, 2012 Part of why I share AppleScripts here on Veritrope.com is so that interested people can contribute and help take a project to the next level. When I first published the original version of this script in September 2010 (and, of course, especially in the days after Yahoo announced they were getting rid of Delicious), I heard from several people who had found ways to improve or fix things. Their additions are a big part of why this AppleScript has worked well for so many people.

But Chris Rasmussen of digitalformula.net went even further. He rolled up his sleeves and modified the code into a "2.0 Version" of the script. I think it's a major step forward and I really appreciate the thought and care he put into it.

Paraphrasing the main thought behind the changes in Chris's version -- When you're using a script that is intended to be run once only, having more dialog boxes to select options is better way to go. In essence, his script allows you to customize how the original script works without having to edit the source code -- and adds additional options like using the bookmark title as the note title. He also reworked the bookmark link verification section to move the "bad links" into a separate, local notebook so that each item could be viewed individually (as opposed to the approach I took which added them to a single "Bad Bookmarks" note). After testing it out, I think these are substantial improvements and make for a much more usable script!

In fact, I was so inspired by his approach that I made a few more contributions of my own -- and I am happy to share the resulting code with you here!

What do you think? Your feedback is essential -- so leave a comment below or send me a note on Twitter!

And remember -- if you want to share your modified (or original) scripts with your fellow Mac users, just use the Script Submission Form to forward it along.

The Code

(*
http://veritrope.com
Delicious Bookmark Importer for Evernote
Version 2.5
(Original Veritrope.com 1.x Code Modified by Chris Rasmussen, digitalformula.net)
March 14, 2012

Status, Latest Updates, and Comments Collected at:
http://veritrope.com/code/delicious-bookmark-importer-for-evernote/

-- CHANGELOG FOR v2.5 (Justin)
        Fix for untitled items
       
-- CHANGELOG FOR v2.4 (Justin)
        Workaround for Note Titles Which Contain Apostrophes

-- CHANGELOG FOR v2.3 (Justin)
        Improved Dialog Boxes
        Added Import Completion Alert
        Improved Verification of Links
        HTML Entity Decode for Bookmark Titles
        Added Cancel / Error Handling
        Removed Extraneous Code
        Added Additional Comments
        Standardized Script Format

-- CHANGELOG FOR v2.0 - 2.2 (A Major Update By Chris Rasmussen)
        Bad bookmarks are now added to a notebook called 'Bad Bookmark list' (createNote method changed to allow that)
        Added prompt for verifying URL
        Added prompt for saving notes with actual title as title or URL as title
        Added prompt for location i.e. U.S. or Japan or everywhere else
        Added prompt for saving the bookmark or full page as the note's content (recommended for Evernote premium users, only)

        (Note : The above prompts would usually be too many but since this script is probably intended to be run once only,
        more options are better than none)
*)


(*
======================
/// EDITABLE SCRIPT PROPERTIES
======================
*)


-- TITLE FOR DIALOG PROMPTS
property scriptTitle : "Import Delicious Bookmarks Into Evernote"

-- SET THE VARIABLE BELOW TO THE NAME OF THE EVERNOTE FOLDER TO USE FOR IMPORTED BOOKMARKS
property EVnotebook : "Delicious Import"

-- NOTEBOOK FOR BAD BOOKMARKS (LOCAL ONLY)
property badNotebook : "Bad Bookmark List"

(*
======================
/// OTHER SCRIPT PROPERTIES
(USE CAUTION WHEN CHANGING VALUES)
======================
*)


property linkList : {}
property theTags : {}
property linkExists : ""
property theCount : ""
property badCount : ""

property NewEncodedText : ""
property theDecodeScript : ""

(*
======================
/// MAIN PROGRAM
======================
*)


try
   
    -- FIRSTLY, CREATE THE 'BAD BOOKMARKS' NOTEBOOK
    -- WE DO THIS NOW BECAUSE OTHERWISE APPLESCRIPT WILL, BY DEFAULT, CREATE A SYNCHRONISED NOTEBOOK
    -- ALSO, IF WE DON'T CHECK TO SEE IF THE NOTEBOOK EXISTS FIRST, AN ERROR WILL BE THROWN IF THE NOTEBOOK ALREADY EXISTS
    tell application "Evernote"
        if (not (notebook named badNotebook exists)) then
            create notebook badNotebook with type local only
        end if
    end tell
   
    -- PROMPT THE USER FOR THEIR LOCATION
    set location to (display dialog "Please Choose Your Location:" buttons {"U.S.", "Japan", "Outside Japan / U.S."} default button "U.S." with title scriptTitle ¬
        with icon path to resource "Evernote.icns" in bundle (path to application "Evernote"))
    if button returned of location = "U.S." then
        set formatDates to "YES"
    else if (location = "Japan") then
        set formatDates to "JP"
    else
        set formatDates to "NO"
    end if
   
    -- VERIFY BOOKMARK URLS?
    -- IF THE USER RESPONDS IN THE AFFIRMATIVE, ALL URLS WILL BE VERIFIED AS WORKING BEFORE THEY'RE ADDED AS NOTES
    -- IF THE USERS RESPONDS IN THE NEGATIVE, URLS ARE NOT VERIFIED AND WILL BE ADDED EVEN IF THEY DON'T WORK
    set verifyResult to (display dialog "Verify URLs Before Import?" buttons {"Yes - Verify All URLs", "No - Just Import Everything", "Cancel"} default button "Yes - Verify All URLs" cancel button "Cancel" with title scriptTitle ¬
        with icon path to resource "Evernote.icns" in bundle (path to application "Evernote"))
    if button returned of verifyResult = "Yes - Verify All URLs" then
        set verify to true
    else
        set verify to false
    end if
   
    -- USE BOOKMARK TITLE OR URL AS NEW NOTE'S TITLE?
    -- THE ORIGINAL SCRIPT ADDED NOTES WITH THE BOOKMARK'S URL AS THE NOTE TITLE
    -- THIS WILL ALLOW THE USER TO KEEP THIS OPTION, IF THEY LIKE, OR HAVE THE NOTES' TITLE AS THE BOOKMARK TITLE (BETTER, IN MY OPINION)
    set titleResult to (display dialog "Use Bookmark URL or Title as Note Title?" buttons {"Use Bookmark's Title", "Use Bookmark's URL", "Cancel"} default button "Use Bookmark's Title" cancel button "Cancel" with title scriptTitle ¬
        with icon path to resource "Evernote.icns" in bundle (path to application "Evernote"))
    if button returned of titleResult = "Use Bookmark's URL" then
        set titleType to "url"
    else
        set titleType to "title"
    end if
   
    -- SAVE THE PAGE'S FULL CONTENT AS THE NOTE'S CONTENT?
    -- IF THE USER RESPONDS IN THE AFFIRMATIVE, THE PAGE'S ENTIRE CONTENT WILL BE SCRAPED AND SAVED AS THE NOTE'S BODY
    -- THIS IS ONLY RECOMMENDED FOR EVERNOTE PREMIUM USERS
    set pageResult to (display dialog ¬
        "Save Full Web Page As Note's Content?
(This Is Only Recommended For Evernote Premium Users Or Small Bookmark Lists)"
buttons {"Yes - Save Full Page", "No - Save summary only", "Cancel"} default button "Yes - Save Full Page" cancel button "Cancel" with title scriptTitle ¬
        with icon path to resource "Evernote.icns" in bundle (path to application "Evernote"))
    if button returned of pageResult = "Yes - Save Full Page" then
        set contentType to "full"
    else
        set contentType to "summary"
    end if
   
    -- RESET VALUES BEFORE BEGINNING
    set AppleScript's text item delimiters to ""
    set linkList to {}
    set theCount to 0
    set badCount to 0
   
    -- SELECT THE HTML FILE
    set deliciousFile to (choose file with prompt "Choose Delicious Bookmark Export File")
   
    -- OPEN THE HTML FILE
    set deliciousData to read deliciousFile
    set deliciousBody to my extractBetween(deliciousData, "<dl>", "</dl>")
   
    -- MAKE A LIST OF ALL LINKS EXTRACTED FROM EXPORT FILE
    set delDelimiter to "<dt>"
    set deliciousRAW to read deliciousFile using delimiter delDelimiter
    my processLinks(deliciousRAW, linkList)
   
    -- PROCESS EACH LINK INTO A SEPARATE WEBCLIPPED NOTE IN EVERNOTE, KEEPING TAGS AND DATES INTACT
    my evernoteImport(linkList, theTags, formatDates, verify, titleType, contentType)
   
    -- ANNOUNCE COMPLETION OF IMPORT
    activate
    display dialog "IMPORT COMPLETED!

"
& theCount & " Links Imported to
"
" & EVnotebook & "" Notebook.

"
& badCount & " Links Need Review in
"
" & badNotebook & "" Notebook." with title scriptTitle buttons {"Exit"} with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
   
    -- ERROR HANDLING
on error number -128
    display dialog "Import Cancelled!" with title scriptTitle buttons {"Exit"} with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
end try


(*
======================
/// SUBROUTINES
======================
*)


-- FIND DELICIOUS HREF INFORMATION
on processLinks(deliciousRAW, linkList)
    repeat with i from 1 to (length of deliciousRAW)
        set theItem to item i of deliciousRAW
        if theItem contains "A HREF" then
            set end of linkList to theItem
        end if
    end repeat
end processLinks

-- PROCESS EACH LINK'S DATA
on evernoteImport(linkList, theTags, formatDates, verify, titleType, contentType)
    repeat with i from 1 to (length of linkList)
        set theItem to item i of linkList
       
        -- EXTRACT DATA FROM BOOKMARK FILE
        set theURL to my extractBetween(theItem, "A HREF="", """)
        set linkExists to "true" as boolean
        set epochseconds to my extractBetween(theItem, "ADD_DATE="", """)
        set deliciousTags to my extractBetween(theItem, "TAGS="", """) --as list
        set itemTitle to "Untitled"
        try
            set itemTitle to my extractBetween(theItem, "">", "</A>")
        end try
        -- UTF-8 CONVERSION OF TITLE / DECODE ANY HTML ENTITIES IN TITLE
        set NewEncodedText to do shell script "
echo " & quoted form of itemTitle & " | iconv -t UTF-8 "
       
        --SINGLE QUOTE WORKAROUND
        set NewEncodedText to my replaceText(NewEncodedText, "
'", "'")
       
        set the_UTF8Text to quoted form of NewEncodedText
        set theDecodeScript to "
php -r "echo mb_convert_encoding(" & the_UTF8Text & ",'UTF-8', 'HTML-ENTITIES' );"" as text
        set itemTitle to do shell script theDecodeScript
       
        -- CHANGE TEXT DELIMITERS TO PARSE TAGS
        set oldDelims to AppleScript's text item delimiters
        set AppleScript's text item delimiters to "
,"
        set theTags to text items of deliciousTags as list
       
        -- CHANGE TEXT DELIMITERS BACK
        set AppleScript's text item delimiters to oldDelims
       
        -- IF THE USER SELECTED TO VERIFY ALL URLS, THE URL WILL BE VERIFIED HERE
        if verify is true then
            my verify_Link(theURL)
        else
            set linkExists to true
        end if
       
        if linkExists is not false then
           
            -- ADD THE BOOKMARK TO THE IMPORT NOTEBOOK
            if titleType = "
title" then
                my createNote(itemTitle, theURL, theTags, epochseconds, EVnotebook, contentType, formatDates)
            else
                my createNote(theURL, theURL, theTags, epochseconds, EVnotebook, contentType, formatDates)
            end if
            set theTags to {}
           
            -- COUNT THE SUCCESS!
            set theCount to (theCount + 1)
           
        else
           
            -- ADD THE BOOKMARK TO THE "
BAD LINKS" NOTEBOOK
            if titleType = "
title" then
                my createNote(itemTitle, theURL, theTags, epochseconds, badNotebook, contentType, formatDates)
            else
                my createNote(theURL, theURL, theTags, epochseconds, badNotebook, contentType, formatDates)
            end if
            set theTags to {}
           
            -- COUNT THE BAD LINK!
            set badCount to (badCount + 1)
        end if
       
    end repeat
end evernoteImport

-- VERIFY WORKING URL
on verify_Link(theURL)
    try
       
        --CHECK THE HTTP HEADER FOR PAGE STATUS
        set the_page to do shell script "
curl -siL "" & theURL & """
        set the_code to items 10 thru 12 of the_page as string
        if the_code is greater than 301 then
            -- THIS VALUE ("
301") WILL SEND MOST REDIRECTS AND ERRORS TO THE "BAD LINKS" NOTEBOOK.
            -- (I CHOSE TO INCLUDE REDIRECTS HERE BECAUSE SOME DNS SERVERS WILL SEND UNKNOWN / BAD LINKS TO THEIR OWN SEARCH PAGE.)
            -- (CHANGE THIS VALUE TO "
400" IF YOU WANT TO EXCLUDE REDIRECTS)
            set linkExists to "
false" as boolean
        end if
    end try
end verify_Link

-- CREATE NOTE IN EVERNOTE
on createNote(itemTitle, theURL, theTags, epochseconds, notebookName, contentType, formatDates)
    tell application "
Evernote"
        try
            set createDate to my epoch2datetime(epochseconds, formatDates)
            -- CREATE THE NOTE BASED ON USER'S CHOICE OF SUMMARY OR ENTIRE PAGE CONTENT
            if contentType = "
full" then
                -- SAVE ENTIRE PAGE (THIS IS THE ORIGINAL SCRIPT)
                set n to create note from url theURL created createDate notebook notebookName tags theTags
            else
                -- SAVE SUMMARY ONLY (NEW OPTION, GOOD FOR EVERNOTE BASIC ACCOUNT HOLDERS)
                set n to create note title itemTitle with text theURL created createDate tags theTags notebook notebookName
                set source URL of n to theURL
            end if
        end try
    end tell
end createNote

-- CONVERT UNIX EPOCH TO DATE/TIME
on epoch2datetime(epochseconds, formatDates)
    -- ADAPTED FROM SCRIPT FOUND AT ERIK'S LAB
    -- (http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/)
    set myshell1 to "
date -r "
    if formatDates is "
YES" then --ADDED DATE FORMAT SWITCH HERE
        set myshell2 to "
"+%m/%d/%Y %l:%M %p"" -- Formatted for U.S.
    else if formatDates is "
JP" then
        set myshell2 to "
"+%Y/%m/%d %l:%M %p"" -- Formatted for Japan
    else
        set myshell2 to "
"+%d/%m/%Y %l:%M %p"" -- Formatted for Everyone Else
    end if
    set theDatetime to do shell script (myshell1 & epochseconds & myshell2)
    return date theDatetime
end epoch2datetime

-- EXTRACT TEXT BETWEEN HTML TAGS
on extractBetween(SearchText, startText, endText)
    set tid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to startText
    set endItems to text of text item -1 of SearchText
    set AppleScript's text item delimiters to endText
    set beginningToEnd to text of text item 1 of endItems
    set AppleScript's text item delimiters to tid
    return beginningToEnd
end extractBetween

--REPLACE
on replaceText(theText, serchStr, replaceStr)
    set tmp to AppleScript's text item delimiters
    set AppleScript's text item delimiters to serchStr
    set theList to every text item of theText
    set AppleScript's text item delimiters to replaceStr
    set theText to theList as string
    set AppleScript's text item delimiters to tmp
    return theText
end replaceText

56 Responses to “Delicious Bookmark Importer for Evernote”

  1. Will Koffel September 23, 2010 at 8:17 pm #

    Thanks for the latest version. I’ll run it through a larger import set and we’ll see how it fares!

  2. Shane December 1, 2010 at 12:58 am #

    You’ll want the curl line to quote what it is running (ie escaping the args):

    set the_page to do shell script "curl -siL "" & theURL & """
    • Justin Lancy December 1, 2010 at 1:16 am #

      Thanks Shane — Code now updated to escape inline arguments!

  3. Chris Brinker December 15, 2010 at 7:51 pm #

    Also, you may want to make people aware that the “from url” syntax will actually save the full pages to their account. This ended up ballooning up the amount of space I used on my free account.

    I switched the line to “create note” line to:

    create note title theURL with text theURL created createDate tags theTags notebook evNotebook

    and saved a lot of space/transfer

    • Justin Lancy December 15, 2010 at 8:38 pm #

      That’s a good point, Chris! (I sometimes forget that a lot of people don’t have Premium Accounts! 😉 )

    • Trevor Gerzen December 22, 2010 at 3:37 am #

      When using this edit I was wondering is there a way to grab
      the text value of the anchor and add that to the note? I used
      palaniraja’s method to import my links and I like the way it looks,
      but it didn’t add the tags to Evernote’s tag field. It just added
      them to the notes themselves. Screenshot: http://v-t-g.me/a/39 So I
      like the way that looks but your script adds the tags into
      Evernote’s tag field. Obviously, I have the free account so I’m
      trying to save on data.

      • Justin Lancy December 22, 2010 at 12:23 pm #

        Hi Trevor,

        This is the great thing about AppleScript: You can usually hack something together quickly to get exactly what you want.

        To do what you’re talking about we need to first get the Title from the web page. One way you could do that is to add a line in the “on evernoteImport” section of the script. (You’ll notice in the comments that this is the part that processes the link data)

        Right after the “set theURL to…” line, try including this:

        set theTitle to my extractBetween(theItem, ">", return)

        This should grab the text containing the title of the link! We’ll want to pass it through to the part of the script that makes the note, so we need to add “theTitle” to the line towards the end of that section that makes the note:

        my createNote(theURL, theTitle, theTags, epochseconds)

        Remember — you’ll also need to add theTitle to the beginning of the createNote subroutine as well!

        The other half of the equation is to build the anchor….

        In the part of the script that creates the note (createNote), we can build the anchor this way:

        set theAnchor to "<a href="" & theURL & "">" & theTitle & ">"

        Now all that’s left is to tweak Chris’s line to read:

        create note with html theAnchor  title theTitle created createDate tags theTags notebook evNotebook

        Done!

  4. chris December 16, 2010 at 5:19 pm #

    Just wanted to give thanks for the script. With evernote dying this was the only solution I found to do the transfer. THANK YOU!

    • chris December 16, 2010 at 5:20 pm #

      sorry i meant with Deliciuos dying…..

      • Justin Lancy December 16, 2010 at 6:01 pm #

        No problem, Chris!

        FYI — You can actually just import the Delicious HTML Export file into Evernote if you want all the links in a single list or, as Chris Brinker explained above, change the script to import the URLs only.

  5. magu December 16, 2010 at 6:05 pm #

    Just thought I’d add for non-US users that the date format it tries to convert to will cause AppleScript to fail when importing any links in your Delicious account that were created past the 12th of any month.

    That’s because the month/day sequence differs. To fix this, change:

    set myshell2 to " "+%d/%m/%Y %l:%M %p"" -- Formatted for Evernote

    to

    set myshell2 to " "+%m/%d/%Y %l:%M %p"" -- Formatted for Evernote
    • magu December 16, 2010 at 6:06 pm #

      Erm. I copied my fixed version. Just invert the two lines (top is fixed, bottom is the original)

    • Justin Lancy December 16, 2010 at 6:18 pm #

      This is a very good note and I’ve added a reference to it in the script description above. Many Thanks!

      Anyone want to flesh it out further to auto-detect the date formatting so that newer users don’t have to edit the script? 😀

      • Justin Lancy December 18, 2010 at 8:12 pm #

        FYI — I’ve added a “switch” to the script which lets non-U.S. users toggle to their date format!

        • Menelik Seth March 11, 2012 at 8:41 pm #

          Thanks Justin! I’ve already sent a bug report for the Delicious export. Also, using the Diigo export after about 121 notes in, the script crashed. I won’t bother you about that since this script was designed for Delicious; however, if you are interested, I could still submit a bug report with that as well.

  6. Adam Fischer December 17, 2010 at 10:38 am #

    Great work. Thanks for making this available.

    I got to around 400 bookmarks imported, and Evernote crashed on me, does the script check for duplicate links and skip if I were to start over? If not, is there a way?

    thanks very much in advance.

    • Justin Lancy December 17, 2010 at 12:42 pm #

      Thanks Adam!

      It doesn’t check for duplicate links — although I’m open to looking at implementing that if I can figure out a reliable, streamlined way to doing so. Have some ideas about how to do it, but does anybody else have thoughts on this?

  7. JimH December 17, 2010 at 12:13 pm #

    Thanks for the super-useful script. In my initial testing, it chugged along doing the imports quite nicely…with one small issue. Delicious tags containing spaces (plus signs, really) like “OS+X” get imported as being two separate tags like “OS” and X”. I can edit the bookmark HTML file to do something like change the pluses to underscores before importing, but perhaps this would be any easy thing for you to fix in the script.

    • Justin Lancy December 17, 2010 at 3:41 pm #

      Hi Jim,

      I think I can take care of this by tweaking the script… will try to do that ASAP. Check back soon for an update!

      • Justin Lancy December 18, 2010 at 8:13 pm #

        FYI — I think this is fixed in the most recent revision!

  8. vicenteocana December 18, 2010 at 2:08 pm #

    Hi and hallelujah for your script!, I am already testing. I am also experoiencing hangups which are stopping the importation of my near 1300 bookmarks, I’ll try to make smaller chunks of the .htm file.

    I also find that there seems to be no import of the notes attached to several of my bookmarks. I hope you can tweak it as soon as you can…

    BTW I am tweeting your site heavily these days!

    regards

    vicente ocana

    • Justin Lancy December 18, 2010 at 7:55 pm #

      Adding in the notes is a bit of a challenge at the moment — Evernote’s AppleScript has a peculiar issue right now that doesn’t allow us to append text to a note created from a URL.

      I’ve been playing around with grabbing the raw HTML of a page and appending it to the Delicious note…. but it’s going to take some tweaking until I’m happy with the finished result.

      Anybody else have suggestions for how they’d like to see their Delicious notes brought into Evernote? What kind of notes/link format would be the most helpful to you?

      • vicenteocana December 18, 2010 at 8:18 pm #

        Well, for me it would have to go into the message field, after the URL link (i am not importing the whole URL).. What about erasing the and inserting the text after the link, or even before the ? quick and dirty anyway..

        regards

        • vicenteocana December 18, 2010 at 8:20 pm #

          uff, markup not shown… Lets try again

          Well, for me it would have to go into the message field, after the URL link (i am not importing the whole URL).. What about erasing the dd mark and inserting the text after the link, or even before the /a ? ok, i know i know, quick and dirty anyway 🙂

          regards

          • Justin Lancy December 18, 2010 at 8:59 pm #

            Instead of making a note with the webpage loaded in it, would something like this be more of what you had in mind?:

          • Robert December 19, 2010 at 12:56 am #

            That’s ugly. Please retain the script as it is (get the current HTML with curl) or just fill the note with the Delicious “notes”.

  9. JJ December 18, 2010 at 6:59 pm #

    Justin
    Thanks for the backdoor – slow but effective – 1800 Delicious bookmarks later …
    I can’t believe that Evernote didn’t immediately include this in a release – kudos for nimbleness.
    You should sell your traffic back to Evernote for a ‘groupon-like’ discount for everyone implementing your script ; >

    • Justin Lancy December 18, 2010 at 7:49 pm #

      Thanks for the nice complement! 😉

      The script is a work-in-progress — but I’m very happy that it’s already helping people like you back up your links!

  10. Robert December 19, 2010 at 12:43 am #

    If you’re like me and have a lot of bookmarks (2000+) and are having a Free account, you should import the bookmarks in an offline notebook first to save your monthly upload limit. After the import you can move notes to a synced notebook as you like.

    • Justin Lancy December 19, 2010 at 12:52 am #

      This is a good approach for Evernoters with free accounts — and a good opportunity to clean out some cruft from your bookmarks! 😉

  11. Stephen Kinsella December 19, 2010 at 1:44 pm #

    Wonderful, thank you!

  12. palaniraja December 21, 2010 at 7:24 am #

    Hi,

    I wrote a js script to convert delicious xml to evernote .enex file to import with tag support.

    Tested on both Mac/Windows version.

    http://dr-palaniraja.blogspot.com/2010/12/import-delicious-bookmarks-to-evernote.html

  13. shrop December 27, 2010 at 9:59 am #

    Worked great! Just imported my bookmarks and closed my
    delicious account. Thanks for the work on this.

  14. Steven January 25, 2011 at 6:21 pm #

    This is gonna be a lifesaver. One issue I faced: the full clip isnt looking right. When I clip with the Google Chrome Extension, the note itself looks very similar in Evernote to the live page. When I use this script, (or testing in AppleScript without your script) the images and text are saved, and everything goes in fine, except that it seems the CSS which controls the layout isnt being saved properly.

    Any idea why?

    Here is a comparison:
    After I import it via script:
    http://twitpic.com/3teb0o

    Live sitE:
    what it should look like:
    http://twitpic.com/3tebbv

    and here is the same note if i clip it via Evernote Extension:
    http://twitpic.com/3tec0i

    Do you have any idea why this is happening?

    Lastly, I would like to have the updated date the same as the created date, so this way when I import the notes I import appear at the bottom of my archive, and wont drown out my newest links Ive directly entered into evernote. Im assuming setting the dates to old dates would do this. The created is being set right, how do i get the updated to be the same as created (vs the day of import)?

    Thanks so much for this!!
    Steve

    • Justin Lancy January 25, 2011 at 7:44 pm #

      Hi Steve — Thanks for the kind note!

      I think the reason you’re getting different formatting is that Evernote processes the HTML of items added as Website URLs (what we’re doing here) differently than if we had created them as notes from an HTML source (what I think the Clipper is doing). Other than rewriting the script to download and clean up the HTML, there’s not a lot that can be done other than raise the issue with the Evernote team.

      Happily, making the updated date match the creation date should be an easy fix! In the “on createNote” subroutine, try adding this code directly after the “set n to create note…” line:

      set modification date of (item 1 of n) to createDate

      Haven’t tested it, so let us all know if it works for you!

  15. Heath January 29, 2011 at 3:53 am #

    I am experiencing the Evernote crash issue. I am using up-to-date OSX.

    I can see in the activity log that Evernote gets caught up on some links (not sure, but it seems to be slow loading sites), however the script just keeps adding items to the que.

    This gets to where there are hundreds in the que. Both times I’ve stopped the script then Evernote crashes and I lose everything.

    In the script (I don’t know the language) it seems the delay 3 is how long it waits before loading another item, so I suppose I could make this larger. What might be better is one of two things: either a pause button of some kind to let the que catch up, or instead of a delay maybe there is a way to check if the link exists as a note before continuing. I have over 2000 links.

    I’ve also found a bug where a Note is created that is over 250 characters long. Because of that it won’t let any of the imported notes be saved and when you exit you loose everything.

    • Justin Lancy January 29, 2011 at 11:45 am #

      Hi Heath,

      Can you send me a copy of your Delicious export file so I can zero in on what the issue is? You can use the Bug Reporter Form and attach the file there…

      Thanks!

  16. thom February 5, 2011 at 7:32 pm #

    Great work! Could it be made even better by adding the site’s URL as the source URL of the Evernote note? Then 1-click bookmark browsing would be possible.

  17. Chris June 13, 2011 at 7:29 am #

    Hi,

    The script works for me, mostly. However, I’ve got 2428 bookmarks on Delicious and this script only copied 906 of them. I also made the change suggested above and found the notes were titled with the bookmark’s URL … not sure if this is right but, if so, no problem (just thought I’d mention it).

    I think it may have been the verify_Link method causing it me to get “only” 906 bookmarks in my notebook. I removed that call and it’s currently up to 1083 bookmarks and still going.

    All I need to do now is find out how to get the bookmark’s title and use that instead of the bookmark’s URL as the note title.

    • Chris June 13, 2011 at 8:35 am #

      Hi, again.

      1. I’ve added the following line below the line that sets the variable ‘deliciousTags’ within the evernoteImport method:

      set itemTitle to my extractBetween(theItem, "">", "</A>")

      2. I’ve changed the line that begins with ‘my createNote’ to:

      my createNote(itemTitle, theURL, theTags, epochseconds)

      3. I’ve changed the ‘createNote’ method to (note that I’m not saving the entire’s page’s content):

      --CREATE NOTE IN EVERNOTE
      on createNote(itemTitle, theURL, theTags, epochseconds)
          tell application "Evernote"
              try
                  set createDate to my epoch2datetime(epochseconds)
                  set n to create note title itemTitle with text theURL created createDate tags theTags notebook evNotebook
              end try
          end tell
      end createNote

      That will get the title of the bookmark from between the markup terminator on the bookmark’s tags (“>) and the anchor terminator ().

      It works well. 🙂

      • Justin Lancy June 13, 2011 at 12:21 pm #

        Hi Chris — Thanks for this awesome contribution!

        In fact, I think this is worthy of its own entry in the Code Library… would love for people to have several script options to choose / learn from!

        Could you use the Script Submission form to send the complete compiled code? Once it’s live, I’ll add a link on this page to alert people to it!

        • Chris June 13, 2011 at 10:13 pm #

          Sure, I don’t mind doing that. I’ll throw it on my own website, too, but point original credit back here. Let me know what you think of my changes – I think they make it a bit more user-friendly and maybe usable by non-tech types. 🙂

        • Chris June 13, 2011 at 11:41 pm #

          I’ve just submitted v2.1 of my version – it puts bad bookmarks into a notebook called ‘Bad Bookmark List’. It’s much easier to manage afterwards as bad notes still be kept as complete notes, without the need to go through the single massive note that previously contained the list of bad URLs. 🙂

          • Chris June 14, 2011 at 8:08 am #

            Just did the final run of all my bookmarks using my updated version. 2628 bookmarks were successfully processed (236 of them were put into the ‘Bad Bookmark List’ notebook) and all options were honoured properly, as listed in the submitted version.

            I’d call that successful. 🙂

          • Ilhan October 11, 2011 at 1:13 pm #

            Will this script work with the newer Delicious interface? I believe there have been some updates recently. Thanks.

          • Justin Lancy October 12, 2011 at 12:30 pm #

            Not sure, as I don’t have any bookmarks at the new Delicious. Anybody have an answer to this?

  18. Bruno October 21, 2011 at 6:03 am #

    When I use the script and go through all the options (tried all the ways), I finally (when it’s supposed to actually import) get this:

    Warning: Unexpected character in input: ” (ASCII=92) state=1 in Command line code on line 1

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in Command line code on line 1

    Have not seen it in the comments here. Ehat could be wrong? Just upgraded to premium but that does not solve the problem. I have about 2000 bookmarks in Delicious.

    Would love to transfer them this month though and then get back to free version of evernote.

    Hope anyone can help me out, as I’m not a scripter.

  19. Bruno October 21, 2011 at 7:03 am #

    Hi again,

    Funny enough this script seems to works fine when I import an export file (GoogleBookmarks.html) into Evernote. Weird… so it must not be the script but the Delicious export file (html file).

    • Justin Lancy October 21, 2011 at 4:10 pm #

      Hi Bruno,

      If you like, you can send me a copy of your Delicious export file and I can take a look to see if I can figure out what the issue is.

      Just use the Bug Reporter Form and attach the file there…

  20. Markus October 25, 2011 at 4:51 pm #

    Thanks for creating this script! Unfortunately it exits with the bellow error after processing the first few bookmarks (last couple of lines included for reference):

    tell current application
    do shell script “echo ‘College of Europe – Master’\”s in European Studies in Bruges and Natolin (Warsaw)’ | iconv -t UTF-8 ”
    –> “College of Europe – Master’s in European Studies in Bruges and Natolin (Warsaw)”
    do shell script “php -r “echo mb_convert_encoding(‘College of Europe – Master’\”s in European Studies in Bruges and Natolin (Warsaw)’,’UTF-8′, ‘HTML-ENTITIES’ );””
    –> error ”
    Parse error: syntax error, unexpected T_NS_SEPARATOR in Command line code on line 1″ number 254
    Result:
    error ”
    Parse error: syntax error, unexpected T_NS_SEPARATOR in Command line code on line 1″ number 254

    Can you tell me what’s wrong here and how I can fix it? Thanks!

  21. Ralf October 26, 2011 at 3:07 am #

    Hi,

    I’ve got a similar issue like Bruno. On importing (after the options) I get this:

    Parse error: syntax error, unexpected T_NS_SEPARATOR in Command line code on line 1

    The result is that only four or seven bookmarks get imported.

    I haven’t found any other way to batch import Delicious bookmarks as web clips into Evernote. I hope I can get it to work with some hints… Thanks a lot for this script to Justin and Chris!

  22. Menelik Seth March 11, 2012 at 8:24 pm #

    I’ve tried to use the script with my Delicious export, and it crashed. I’ve submitted a bug report already.

    I just wanted to comment to note that, so far, the script is working like a charm on my Diigo export (using the Delicious Format). So that makes me wonder what’s up with the Delicious exporter.

    Excellent script!

    • Justin Lancy March 11, 2012 at 8:35 pm #

      Hi Menelik,

      Feel free to send me a copy of your Delicious export file using the Bug Report form and I’ll try to debug things from here!

      • Menelik Seth March 11, 2012 at 8:52 pm #

        Diigo export sent! 😀 thanks again!