Jump to content

cmt73

Level 1
  • Posts

    2
  • Joined

  • Last visited

Posts posted by cmt73

  1. I wrote and awk script:

    1. Export from Diigo as CSV tab-delimited 
    2. Clean up the file a bit, remove empty lines (mine had several)
    3. Replace all ampersands in the URL's with & for URL encoding - it was quicker to just do that then figure out awk's gsub() issues with ampersands.
    4. Run the awk script on the file and basically that was it.

    My first couple tries I was getting errors because of the ampersands, but otherwise that's it.

    usage:

    ./parse-evernote.ksh diigo.csv > diigo-export-full.enex

    Here's the ksh script:

    ------------

    #!/bin/ksh

    cat $1 | awk -F'\t' '
            BEGIN {
                    print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
                    print "<!DOCTYPE en-export SYSTEM \"http://xml.evernote.com/pub/evernote-export3.dtd\">";
                    print "<en-export export-date=\"20160520T205637Z\" application=\"Evernote\" version=\"Evernote Mac\">";
             }
            {
                    printf("\t<note>\n\t\t<title>%s</title>\n\t\t<content><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">%s<br/><a href=\"%s\">%s</a><br/>%s<br/>%s<br/>%s<br/></en-note>]]></content>\n\t\t<created>20160520T205637Z</created>",$1,$1,$2,$1,$4,$5,$6);
                    tags=$3;
                    split(tags,tagArray,",");
                    if(NR>1) {
                            for (i=0; i<length(tagArray); i++) {
                                    if (length(tagArray) > 0) printf("\n\t\t<tag>%s</tag>",tagArray);
                            }
                    }
                    printf("\n\t\t<note-attributes><source-url>%s</source-url></note-attributes>\n\t</note>\n",$2);
            }
            END { print "</en-export>"; }
    '

    • Like 1
×
×
  • Create New...