Droplet (Mac OS) for Launching KindleGen
Posted by Antone Roundy under Technology Add Your Comments
If you use Amazon’s KindleGen program to generate Kindle eBooks on the Mac, I’ve got a little script for you that will enable you to drag-and-drop your source material and run KindleGen automatically, rather than having to open a Terminal window and type filenames and paths on the command line.
Copy the following code and paste it into AppleScript Editor, and then save it as an Application. Once you’ve done that, you’ll be able to drag and drop HTML files, .opf files, etc. onto it to create your Kindle eBooks.
Note: you’ll either need to put kindlegen in your Applications folder, or fix the path to it near the bottom of the code.
on replace_chars(this_text, search_string, replacement_string)
set text item delimiters of AppleScript to search_string
set item_list to text items of this_text
set text item delimiters of AppleScript to replacement_string
set this_text to item_list as string
set text item delimiters of AppleScript to ""
on open filelist
tell application "Terminal"
if (count of windows) is 0 then
do script ""
repeat with i in filelist
tell application "Finder" to set parentFolder to quoted form of (POSIX path of ((folder of i) as string))
set fn to my replace_chars(name of (info for i), " ", "\\ ")
do script "cd " & parentFolder in window 1
do script "/Applications/kindlegen " & fn in window 1