Mobileread
Applescript Wrapper Application for Kindlegen
#1  pdurrant 04-27-2010, 08:56 AM
KindleGen is a Mac OS X 10.5 and above Intel-only program from Amazon that compiles ebook source files into a Kindle format ebook.

Unfortunately, it's a command-line program that normally needs to be run by typing commands using the Terminal utility.

So I wrote an Applescript wrapper for Kindlegen. To use it, download and expand the attached zip file, which will give you the KindleGen Wrapper 2.2.app Applescript application. You can put this anywhere — perhaps in your Applications folder.

You'll also need the Mac OS X version of Kindlegen from Amazon, which can be found here: http://www.amazon.com/gp/feature.html?docId=1000765211.

Expand the zip file from Amazon, which will give you a folder containing the kindlegen command-line application (called just "kindlegen") and a variety of notes and samples. I suggest you drag the kindlegen command-line application into the Applications folder.

To use the Applescript, just drag&drop an ePub file or a folder containing a suitable set of Kindle source files onto the KindleGen Wrapper Applescript.

For ePubs the kindle file will be created in the same folder as the ePub, with the same name but with a ".mobi" extension.
For folders, the Applescript will run KindleGen on the first .opf file it finds in any folder (including in subfolders), and create the compiled Kindle file in the folder that contains the folder that was dragged, named the same as the folder that was dragged, but with a ".mobi" extension.

You can drag multiple folders and/or ePub files at once.

Because the Applescript searches subfolders, it's possible to arrange your source files so that they are both a valid ePub folder, and valid source files for a Kindle file, and generate the Kindle file with this AppleScript, and the ePub file using my ePub Zip applescript.

If you just run the AppleScript by double-clicking it you'll be able to choose whether kindlegen is run with the 'don't append source' option, with no compression (fast) or high compression (small). You'll also be shown which kindlegen command line application is being used, and be given an opportunity to choose a new one.

Comments, bug reports, etc., welcome.

This script now works only with kindlegen 1.2 and above, including the latest kindlegen 2.9. The option to not include source files will only work with later versions of KindleGen (2.0 and above?).

If you want to split out the Mobipocket and KF8 versions of the compiled file, see the KindleUnpack python script and AppleScript.

New to version 2.0:
New to version 2.1
New to version 2.2
kindlegen.png 
[zip] KindleGen Wrapper 2.2.app.zip (294.2 KB, 1725 views)
Reply 

#2  nathalil 09-01-2010, 07:33 AM
Hi pdurrant,
thank you very much for putting all this infos and zips here, but I still don't get it.

From Amazon I got a ZIP, unpacked it and dragged it to the Application Folder.
I also dragged the unpacked Kindlegen 1.1 app in applications and dragged it on Appleskript.

What's next?
or what did I do wrong?

When I try to compile my book with eCub it says:
*** Compilation failed.
The kindlegen command was empty. MobiPocket file not generated.

how do I generate this command?

when I type ~/KindleGen/kindlegen
it says: No such file or directory

despair.
thanks
Reply 

#3  pdurrant 09-01-2010, 08:13 AM
Quote nathalil
When I try to compile my book with eCub it says:
*** Compilation failed.
The kindlegen command was empty. MobiPocket file not generated.

how do I generate this command?

when I type ~/KindleGen/kindlegen
it says: No such file or directory
This Applescript is nothing to do with eCub. If you want to use KindleGen with eCub, check the eCub documentation.

This Applescript allows you to drag&drop a folder of ePub source (what you get by unzipping an ePub) onto the AppleScript to run KindleGen on the .opf file in that ePub source folder.
Reply 

#4  pdurrant 07-30-2011, 07:07 AM
Significantly upgraded the script to work with the latest kindlegen 1.2, and to give you the option of compiling quickly, or compiling small files.

See the first post for the new AppleScript.

[EDIT: Applescript should now run in 10.5, 10.6 and 10.7.]
Reply 

#5  gdgibson 08-26-2011, 09:57 AM
This is the first time I have ever gotten Kindlegen to work on my Mac. I don't know what I've been doing wrong - probably some weird thing I don't understand in Terminal - but now I finally have a way to produce Mobi files without Calibre.

(Not that there's anything wrong with Calibre, but it's nice to be able to convert without it as a means of debugging.)
Reply 

#6  amyg 02-15-2012, 04:02 PM
I would love an updated version of this applescript to run the new kindlegen 2.3 that I just downloaded. I tried using this one and it didn't work. I was able to edit pdurrant's lovely applescript wrapper for epubcheck to work with the new version of that, but, alas, I am too much of an applescript novice to edit this one myself.

Edit: Actually, it does run (just takes longer than the old one) and creates the mobi file, but I get an error message: The variable opfFilePath is not defined. But the mobi file looks fine so maybe I don't need a new one.
Reply 

#7  pdurrant 06-03-2012, 05:30 PM
Quote amyg
I would love an updated version of this applescript to run the new kindlegen 2.3 that I just downloaded.
A new version has just been uploaded. This fixes the problem with the opfFilePath undefined error message, and removes explicit references to kindlegen 1.2, as it also works with later versions.
Reply 

#8  amyg 06-18-2012, 12:26 PM
Thanks for this. Works like a charm!
Reply 

#9  pdurrant 09-29-2012, 07:52 AM
Just updated to version 2.0

New to version 2.0:
See the first post for the download.
Reply 

#10  pdurrant 10-22-2012, 09:49 AM
Just updated to version 2.1

New to version 2.1:
See the first post for the download.

(Yes, I have done an update for just the icon. I've found using ePub Zip/Unzip, epubcheck and MobiUnpack a lot easier since I added icons.)
Reply 

  Next »  Last »  (1/4)
Today's Posts | Search this Thread | Login | Register