In recent months the length of time it was taking to run my applescript version of the Kindle Helper Scripts was getting out of hand. It was upwards of 3 hours. Time for a refactor. As I wrote at the time my knowledge of applescript was basic so this wasn’t a great suprise. I decided to rewrite using ruby as I’m doing some ruby scripting at work. And as it is vaguely related to my day job I got to spend a couple of hours doing it as part of a hack afternoon. It is always good to have a real project to practice new languages in after all.

The new script takes seconds to run instead of hours. So is much more usable. It runs from the command line. It has 3 parameters, the first 2 of which are essential:

  • Parameter 1: path to the My Clippings.txt file
  • Parameter 2: path to the folder where the output is to go
  • Parameter 3: (optional) an indicator that the location should be output (i.e. page number, line number etc)

Here’s how I call it:

ruby parse\_my\_clippings.rb "/Users/jane/Dropbox/My Clippings.txt" "/Users/jane/Dropbox/Clippings"

I’ve tested it using ruby 2.1.2 on a mac. And a different 2.0+ version on a pc. It works using the format of My Clippings.txt from my kindle (which is in English). If you have a different set up to this then YMMV.