A Little Service That Converts Files to EPUB Format

My wife recently gave me a nice gift: a Sony Reader device. She'd been watching me read books using the Kindle for iPhone app, and felt sorry for me because I had to read from such a small screen. The Reader is really nice. (Thanks, honey.)

Now I'm learning all about how to get content onto the device. The Sony eBookLibrary software that you use to copy files to the device is pretty bad (worse than iTunes, if you can believe that), so I'm using it as little as possible. I ran across calibre, a nice open-source tool for managing various e-reader devices. Unfortunately, it can't handle the DRM'ed files that one downloads from the Sony eBookstore, and after transferring books to the device, the device often crashes and has to reboot itself.

So, my compromise for now is to use calibre's ebook-convert command-line utility to convert files to EPUB format, and then use Sony eBookLibrary to transfer those to the device. To make this easier, I've created a service, using Automator, that will invoke ebook-convert on files selected in the Finder.

If you want such a thing for yourself, here's how to make it:

Install the calibre command-line tools

  1. Download calibre and install it.
  2. Start calibre, and click the Preferences toolbar button.
  3. Select Advanced in the list on the left, and click the Install command-line tools button.

Create the service

(Note: This requires Mac OS X 10.6 Snow Leopard or newer.)

  1. Start the Automator application.
  2. When prompted to choose a workflow template, select Service and click Choose.
  3. In the Service receives selected list, choose documents.
  4. In the in list, choose Finder.
  5. Drag a Run shell script action from the list into the workflow area.
  6. Leave the Shell: option set to /bin/bash
  7. For the Pass input: option, choose as arguments
  8. Change the script text to this:
        for f in "$@"
        do
            /usr/bin/ebook-convert "$f" "$f.epub" --output-profile=sony
        done
    
  9. Choose the File -> Save menu item, and give the service a name like "Convert to EPUB"

To test your new service, go to the Finder and select a text, RTF, PDF, or other such file, and then choose the File -> Services -> Convert to EPUB menu item. Note that conversion may take a while, depending upon how large the input file is.

I am a newbie at this. If there are better ways, I'd love to hear about them.

© 2003-2017 Kristopher Johnson