![]() |
#1 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
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=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
Last edited by pdurrant; 01-25-2019 at 04:15 PM. |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Sep 2010
Device: none
|
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 |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
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. Last edited by pdurrant; 07-30-2011 at 06:12 PM. Reason: Removed out of date info |
|
![]() |
![]() |
![]() |
#4 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
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.] Last edited by pdurrant; 07-30-2011 at 06:13 PM. |
![]() |
![]() |
![]() |
#5 |
Member
![]() Posts: 19
Karma: 10
Join Date: Apr 2011
Device: All
|
Thanks!
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.) |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Enthusiast
![]() Posts: 40
Karma: 56
Join Date: Sep 2011
Location: Los Angeles, CA
Device: Nook simple touch, iPad
|
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. Last edited by amyg; 02-15-2012 at 04:31 PM. Reason: Further testing |
![]() |
![]() |
![]() |
#7 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
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.
|
![]() |
![]() |
![]() |
#8 |
Enthusiast
![]() Posts: 40
Karma: 56
Join Date: Sep 2011
Location: Los Angeles, CA
Device: Nook simple touch, iPad
|
Thanks for this. Works like a charm!
|
![]() |
![]() |
![]() |
#9 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Just updated to version 2.0
New to version 2.0:
See the first post for the download. |
![]() |
![]() |
![]() |
#10 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
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.) |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Mar 2013
Device: Kindle, iPad
|
Hello, I was wondering if your program works on Mountain Lion? I enabled the settings to allow apps not from the Apps store to run but nothing happens when I drag and drop my epub exported from Pages to your KindleGen Wrapper. I kept the KindleGen in the Applications folder as well as inside KindleGen Wrapper's Resources folder. Any ideas on what I can try next?
A quick run- down of my situation... I styled and tagged four 185 page long epub which is a compilation of articles categorized in 5 sections using Pages. I found out after doing this unfortunately, that font sizes, space between paragraphs, and the TOC gets screwed up once exported as ePub. I kept it pretty simple with styles: Title (for title of sections), Heading 1 (for title of articles), Heading 2 (for sub-sections within articles) article Title, Body (for body text). I inserted graphics for the beginning of each section. The TOC that was created in Pages disappeared when viewed on a Kindle. The process has been nothing but frustration and headache after headache! I'm not even sure if your software remedies my problems but at this point I'd like to try any and your solution sounded good because it's the only way I could use Amazon's KindleGen script which they recommend we use... Thank you for any help. |
![]() |
![]() |
![]() |
#12 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Well, it works for me, so it can run on Mountain Lion.
What happens if you double-click it? You should get asked whether you want it to compile Fast or Small, and then get to choose which kindlegen it uses. When you drag&drop, do you get a text file produced? that would show what's happening when it tries to run kindlegen |
![]() |
![]() |
![]() |
#13 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Mar 2013
Device: Kindle, iPad
|
As you say, double click asks whether I want to compile Fast or Small and choose which kindlegen to use. I've tried both.
Drag and drop doesn't produce any text file that I can see. Where would the text file be outputted by default? edit: I tried using a different epub file with only a couple words in it and outputted a .txt file. Inside says, : Permission denied |
![]() |
![]() |
![]() |
#14 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
Umm... you have unzipped the Kindlegen downloaded from Amazon and pointed the AppleScript at the Kindlegen file inside the unzipped folder, haven't you? You haven't just pointed it at the Kindlegen zip file? |
|
![]() |
![]() |
![]() |
#15 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 73,580
Karma: 315126578
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Just uploaded version 2.2 of the wrapper, which restores the ability to not add the source to the end of the generated book, for versions of kindlegen that support that option (e.g. the latest version 2.9 of Kindlegen).
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ePub Zip/Unzip AppleScript application for Mac OS X | pdurrant | ePub | 149 | 12-02-2024 12:51 PM |
Kindlestrip Python script and AppleScript wrapper | pdurrant | Kindle Formats | 137 | 08-15-2017 01:16 AM |
KindleCover: AppleScript wrapper and Python script application | pdurrant | Amazon Kindle | 6 | 12-02-2012 07:14 AM |