Marco Pessoa

Research Scientist (Embrapa).

Genomics, plant genetic resources, and breeding.

contact: marco [at] marcopessoa.com

<< previous post

a fixed version of the "kindle to devonthink" script

how I contributed to a simple open source project

I’m a devoted DEVONThink user ever since I read Steven Berlin Johnson’s book, “Where Good Ideas Come From”. In one of the chapters, Steven describes how he uses DEVONThink to construct a personal database of text entries that were selected by him for any particular reason, either from books, newspapers, or the web. It’s his digital commonplace book.

DEVONThink fits this purpose because in addition to being a tool to store information - text, documents, images, bookmarks, e-mail - it allows you to automatically connect different entries by clicking a button. This feature is perfect to make serendipitous connections between passages about a specific subject, or between things you are writing and your own database. For a great explanation on how this works, check out this post on Steven’s blog.

Later on, I found some useful scripts that would definitely fit my workflow. In summary, I read scientific papers (as pdf files) on an app called Skim. Another frequent source of reading material is the Kindle, where I can highlight lots of interesting book passages. I don’t remember exactly how I found those scripts. One of them allowed me to export my pdf highlights from Skim to Devonthink. The other one allowed me to export my Kindle ebooks highlights from my Kindle Highlights web page to DEVONThink. Both scripts worked perfectly fine, and I was happily collecting text passages that fitted my research interests.

One day, however, the Kindle-to-DEVONThink script stopped working, because Amazon decided to change the way the information was organized on the Kindle Highlight’s page. I sent an e-mail to the author of the script, and he said he wouldn’t be able to work on it immediately. He suggested I looked at it myself, or tried to find someone who knew Perl and AppleScript to fix it. I actually looked at it but couldn’t make sense of it at all. So I decided to wait. Maybe that guy would have some time to do something about it.

My patience only lasted until I finished my next ebook. Finishing my ebooks and not being able to import my highlights into DEVONthink was such a pain that I tried to overcome my noob scripting abilities. Surprisingly for me, I was able made it work! I sent it to Rob Trew, the author of the script, who promptly suggested me to set up a GitHub account and upload a fork of the original project, so I showed up as a collaborator.

Since I’m not really trained in any scripting languages, being able to fix this was a huge personal victory.

Here’s the original description of the script, by Rob Trew, posted on the DEVONThink forum:

I have posted a first draft of a script which imports Kindle notes (highlighted passages and associated user notes) into the selected DEVONthink group.

The script creates RTF notes in the same format as my Sente, Skim, and Mekentosj Papers2 scripts. (A separate DEVONthink group is used/created for each book).

If you have created a custom Devnote.css file for any of these scripts in your scripts folder, it will be used by this script too, and apply the styles which it contains.

As with the other scripts, this aims to facilitate the kind of work-flow described by Steven Berlin Johnson in various articles.

Note that by default the script imports notes from the https://kindle.amazon.com/your_highlights web pages (which have the richest set of data fields, and allow for the creation of some useful hyperlinks in the DT records - jumping, for example, to the relevant passage in the OS X Kindle app).

The script will, however, also offer to import notes from the My Clipping.txt file on a Kindle device, or from any text file which uses the same format.

(The technically curious will find the current draft of the parsing logic in perl files inside the script bundle.

The HTML parsing uses the HTML::TokeParser library, and the TXT parsing uses Date::Parse and Date::Language

As far as I can see these libraries seem to be part of the standard OS X 10.6 perl installation …)

And here’s how to use the new version of the script, as I posted it on the same thread:

The highlight page for a specific book is now accessed from a link in the ebook popular highlights page:

1) Starting from http://kindle.amazon.com/your_highlights, click on a book title. This will take you to the book page that includes shared notes and popular highlights.

2) In the upper right corner of this page there is a link to your personal highlights saying “You have n highlighted passages”. Click on this link.

3) This will lead you to a page with the following URL structure: https://kindle.amazon.com/your_highlights_and_notes/BOOK_ASIN. That’s the page where the script actually works now.

You can download the new script here

KNOWN BUGS: 1) Temporary HTML file is not deleted from Desktop 2) Ebook title is not detected when writing DevonThink files and folders

Please feel free to download the new version of the script and test it. As shown above, the instructions are basically the same for the original script, except for the page you are going to navigate to in order to use it. Last, but not least, the script only works with Safari.

blog comments powered by Disqus