View Single Post
Old 09-05-2009, 09:16 AM   #1
pdurrant
Santa 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: 33,466
Karma: 91309754
Join Date: Jul 2007
Location: Norfolk, England
Device: NOOK ST GlowLight
ePub Zip/Unzip AppleScript application for Mac OS X

Zipping a folder of files to make an ePub isn't as easy the folder 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 <quoted form of ePubFilePath> mimetype
zip -rDX9 <quoted form of ePubFilePath> * -x "*.DS_Store" -x mimetype

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

Comments, bug report, etc, welcome.

New in Version 2.0!
Unzipping an ePub is relatively easy. But it could be easier. This application now unzips ePubs for you, and in addition, it resets the file permissions on the unziped files. No more unzipping an ePub only to find that you don't have permission to read any of the files!

The actual commands used to unzip are:
zip -FF <quoted form of ePubFilePath> --out <quoted form of tempFilePath>
unzip <quoted form of tempFilePath> -d <quoted form of outputFolder>
chmod -R 755 <quoted form of outputFolder>

The application now zips folders into ePubs and unzips ePubs into folders. Drag & Drop or just double-click to run and choose a folder or an ePub.

The new application also has a neat icon, and a crude translation into French. Corrections to the translation very much welcome, as are translations into other languages.

When unzipping, the 2.1 script first uses the zip command to fix any possible errors in the structure of the zip file.

Version 2.0.1: Added german translation by shorshe
Version 2.1: Make sure the zip is good before unzipping it.
Version 2.1.1: Added Portugese translation by PageLab
Attached Files
File Type: zip ePub Zip:Unzip 2.1.1.app.zip (191.9 KB, 6815 views)

Last edited by pdurrant; 11-02-2012 at 09:38 AM. Reason: New version 2.1
pdurrant is offline   Reply With Quote