View Single Post
Old 08-09-2011, 03:33 PM   #38
dejiridoo
Junior Member
dejiridoo began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2011
Device: Kindle
Thumbs up Converter App Worked like a charm

Quote:
Originally Posted by pdurrant View Post
Extracting the files from an ePub is easy - you can just unzip the file and then you get a folder full of the contents of the ePub.

But zipping the folder of files back up into an ePub isn't as easy - it needs to be zipped in a specific way.

Here's an AppleScript application that does all the hard work for you - just drag the folder of files onto the Applescript application, and your epub will be created.

For those interested in what's going on, it's just issuing two zip commands to create the epub, one that zips up the mimetype file without compression, and the second that zips up the rest of the files with compression, skipping the mimetype file and any .DS_Store files or empty directories. The actual commands are

zip -X0 "full path to new epub file" mimetype

and

zip -rDX9 "full path to new epub file" * -x "*.DS_Store" -x mimetype

Thanks to Abecedary and Jellby for help getting the magic incantations right.

Comments, bug report, etc, welcome.

Edit: Bug Fix 1: Using Jellby's suggestion, 1.0.1 now excludes .DS_Store files in subdirectories too

Edit: Enhancement: 1.0.2 now checks for the presence of an existing zip file, and gives the user the option to replace the file or stop. And the old file really does get replaced, as it's moved to the trash before the new one is created. Previously, files left over from the old file could end up being left in the new file.
Fantastic. I had the same problem after trying to edit an EPUB. I successfully edited the book but then when I rezipped, I encountered many problems. (Oddly enough, Calibre could read it.) This little tool instantly solved my problem. Thanks so much for all your help -- one year after you posted.
dejiridoo is offline   Reply With Quote