Mobileread
ePub Zip/Unzip AppleScript application for Mac OS X
#1  pdurrant 09-05-2009, 08:16 AM
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

Version 3.0: Option to expand to a package for use with iBooks.
Version 3.0 (64-bit): For Mac OS X 10.6 and later.
[zip] ePub Zip:Unzip 2.1.1.app.zip (191.9 KB, 13115 views)
[zip] ePub Zip:Unzip 3.0.zip (205.8 KB, 7925 views)
[zip] ePub Zip-Unzip 64 3.0.zip (253.8 KB, 2991 views)
Reply 

#2  dgillette.rm 09-05-2009, 09:07 AM
Thanks, I was wondering what my problem was. I would download an epub and safari would unzip it and then I could not read it.
Reply 

#3  pdurrant 09-05-2009, 09:13 AM
Quote dgillette.rm
Thanks, I was wondering what my problem was. I would download an epub and safari would unzip it and then I could not read it.
To stop Safari doing that, uncheck 'Open "safe" files after downloading' in Safari preferences.
Reply 

#4  Abecedary 09-05-2009, 05:47 PM
Thanks very much (again)! Seems to work perfectly for me so far. And it makes good sense to put the .DS_Store files on the exclude list (though having that other command aliased is handy for quickly clearing those files off thumb drives, etc--I suppose it would be easy to make a droplet for that, too). Cheers!
Reply 

#5  Jellby 09-05-2009, 06:07 PM
Does "-x .DS_Store" catch the files in the subdirectories too?
Reply 

#6  Abecedary 09-05-2009, 06:10 PM
Quote Jellby
Does "-x .DS_Store" catch the files in the subdirectories too?
I would think it'd exclude them recursively, but that's a good question. I'll check on that right now.

EDIT: And no, apparently it doesn't.
Reply 

#7  Jellby 09-06-2009, 04:16 AM
Quote Abecedary
I would think it'd exclude them recursively, but that's a good question. I'll check on that right now.

EDIT: And no, apparently it doesn't.
Try with "-x *.DS_Store" then...
Reply 

#8  Abecedary 09-06-2009, 08:46 AM
Quote Jellby
Try with "-x *.DS_Store" then...
That seems to do it!
Reply 

#9  pdurrant 09-17-2009, 05:34 PM
I've just uploaded a new version. See the first message in this thread.

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.

Quote pdurrant
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.
Reply 

#10  BookLoverToo 10-14-2009, 08:58 PM
Thanks pdurrant. Works like a charm!
Reply 

  Next »  Last »  (1/14)
Today's Posts | Search this Thread | Login | Register