View Single Post
Old 04-27-2010, 08:56 AM   #1
pdurrant
The Ghost Mouse
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 32,219
Karma: 89021440
Join Date: Jul 2007
Location: Norfolk, England
Device: NOOK ST GlowLight
Applescript Wrapper Application for Kindlegen

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=1000234621.

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:
  • Configuration Dialogs improved
  • Compilation option (Fast/Small) is now a default. You can reverse the default by holding down the option key when drag&dropping.
  • You can (if you wish) put the kindlegen command line application inside the KindleGen Wrapper package, in the Resources folder. The configuration dialogs will notice that it's there and give you the option of selecting it.

New to version 2.1
  • Pretty icon

New to version 2.2
  • Apped option to not attach source, since that command line option is supported again.
Attached Thumbnails
Click image for larger version

Name:	kindlegen.png
Views:	204
Size:	160.1 KB
ID:	94658  
Attached Files
File Type: zip KindleGen Wrapper 2.2.app.zip (294.2 KB, 304 views)

Last edited by pdurrant; 05-03-2014 at 05:13 AM.
pdurrant is offline   Reply With Quote