View Full Version : ePub Zip/Unzip AppleScript application for Mac OS X


pdurrant
09-05-2009, 09: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

dgillette.rm
09-05-2009, 10: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.

pdurrant
09-05-2009, 10:13 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.

To stop Safari doing that, uncheck 'Open "safe" files after downloading' in Safari preferences.

Abecedary
09-05-2009, 06: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! :2thumbsup

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

Abecedary
09-05-2009, 07:10 PM
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.

Jellby
09-06-2009, 05:16 AM
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...

Abecedary
09-06-2009, 09:46 AM
Try with "-x *.DS_Store" then...

That seems to do it!

pdurrant
09-17-2009, 06: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.

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.

BookLoverToo
10-14-2009, 09:58 PM
Thanks pdurrant. Works like a charm!:thanks:

kiermel
02-26-2010, 06:42 AM
Thank you very much :thanks:

I had been trying to create something seemed, and I could not do it!

MarcusStringer
03-10-2010, 06:03 PM
You sir...are a gentleman among men...thank you so much for this I was about ready to slip into a coma yesterday when I couldn't work out why this wasn't working....

Croptop
03-24-2010, 09:29 PM
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.


I know that this is an old thread but I wanted to post a big thank you to the OP for making this script available and, more importantly to me, taking the time to explain what the problem is and how it was being solved. Thanks to you and posters on other threads, I can enjoy my purchased .epub books on all of my devices.

Fabe
06-17-2010, 08:04 AM
Thank you. I've been driving myself nuts trying to properly zip files for epub on my Mac. Thank you, thank you, thank you.

David Derrico
07-31-2010, 06:15 PM
You rock super, super hard! This, and your ePubCheck applescript, saved me so much time and frustration. Thank you!!

MichaelGray
09-24-2010, 01:48 PM
Hi there
Hope somebody can help with this - I've been using ePub zip for a while and it's been a fantastic saviour, but suddenly it doesn't seem to work any more. When I try to zip my folder into epub I get an error message: "Can't make <<class ctnr>> of item 1 {alias "Macintosh HD:Users:Mini25:Desktop:nameofmyfolder:"} into type text." I can OK this or press an "Edit" button, which opens the Apple Script Editor (beyond me!)
Not sure what changed on my system or in my epub - it just seems to have changed from one day to the next. Any ideas?
Thanks very much
Michael

pdurrant
09-24-2010, 02:30 PM
Hi there
Hope somebody can help with this - I've been using ePub zip for a while and it's been a fantastic saviour, but suddenly it doesn't seem to work any more. When I try to zip my folder into epub I get an error message: "Can't make <<class ctnr>> of item 1 {alias "Macintosh HD:Users:Mini25:Desktop:nameofmyfolder:"} into type text." I can OK this or press an "Edit" button, which opens the Apple Script Editor (beyond me!)
Not sure what changed on my system or in my epub - it just seems to have changed from one day to the next. Any ideas?
Thanks very much
Michael

Hmm... Well, it's obviously a bug, but exactly what's causing it is a mystery to me at the moment.. It might be that I'm not escaping a path when I should. Try putting the epub folder onto the top level of your hard disk and trying from there. If that works, then it must be something in the path, but I can't see what. When I get a moment I'll see if I can spot anything 'obvious' in the script.

danrodney
10-25-2010, 06:50 PM
First I wanted to thank pdurrant so much for writing the EPUB Zip script!

However I disagree that unzipping is so easy. I've had some EPUBs that do not properly unzip with the Finder's native unzipper (and renaming your files is a pain if you need to do it a lot). Using pdurrant's code as a reference, I went ahead and made an UnZip app that uses the terminal command which I find more reliable.

While I was at it I updated the EPUB Zip 1.0.2.app to remove the confirmation dialog at the end (to speed things up) and make the dialog messages more consistent with the UnZipper I created.

Here's the new version for all to enjoy. It contains:
EPUB UnZip 1.0.app
EPUB Zip 1.0.3.app

Thanks again for your contribution.
Dan

danrodney
10-26-2010, 03:49 PM
When updating the scripts I changed the name from ePub to EPUB because it seemed like the ePub developers wanted it that way.

But I have since changed my mind and went back to ePub because I see more people using it and honestly I like it better. Even the official ePub logo uses a lowercase "e" so they can't even decide which way to go! So no real changes other than the name change, but I still wanted to post it anyway.

wannabee
10-26-2010, 07:56 PM
I've been zipping and unzipping on windows 7 at work with just a right click and assumed that if I had to do it at home on my mac it would be the same. Glad I came across this post and thanks for the script. I'm sending it home straight away.

a-name4epub
12-02-2010, 08:59 PM
Thanks for this, pd. It works, but I am getting errors of a different kind, so will be searching...

wannabee
12-03-2010, 09:57 AM
Spent the day finalising a book. (I hope) must have unzipped, edited and rezipped 30 times. Used 3 press and flightcrew every time to validate with no errors.

No scripts, just right click "extract all" and right click "send to zip file"

pdurrant
12-03-2010, 10:33 AM
Spent the day finalising a book. (I hope) must have unzipped, edited and rezipped 30 times. Used 3 press and flightcrew every time to validate with no errors.

No scripts, just right click "extract all" and right click "send to zip file"

If you're lucky, that might work. It would require the zip to have zipped the mimetype file first, and to not apply any compression to it. I'd advice checking with epubcheck as well, which I know checks that the mimetype file has been done correctly.

wannabee
12-04-2010, 06:38 AM
I'd advice checking with epubcheck as well, which I know checks that the mimetype file has been done correctly.

Thanks for your response. I appreciate it very much.

Now seriously, I was trying to get some tables formatted the way I like and and validated many versions yesterday. All with epubcheck and flightcrew.

As soon as I have a few moments I''ll take that file and modify it for copyright, validate it and post it because I am confused about all this need to use scripts to zip it up.

I have never used a script. I'm using Windows 7 and just using the extract all files option and send to zip from right click then just change the file type. I have four books that validate and could not count how many times I validated them.

Signed - confused

pdurrant
12-04-2010, 06:43 AM
I have never used a script. I'm using Windows 7 and just using the extract all files option and send to zip from right click then just change the file type. I have four books that validate and could not count how many times I validated them.


How interesting. It might be that Windows 7 is clever enough to notice that it's an ePub being zipped, but I think it more likely that the way you have named the files and the folders in your ePub source just happen to give the right result.

So long as it works for you. It certainly doesn't work on Mac OS X if you just use the built-in right-click/Compress (which creates a zip file).

wannabee
12-04-2010, 07:02 AM
I guess you're right. I'll see what the mac does tomorrow when I get some time.

Juris
12-26-2010, 04:50 AM
Hello,
I hope this is the proper forum for the questions I have.

I bought and downloaded an epub book with Adobe DRM. I wanted to read it on my iPad and used ineptepub to strip the drm. It only returned the first 18 pages of the book, the rest were blank.

i used several versions of ineptkey and ineptepub and got the same result.
I then made a copy and using your scripts unzipped and then rezipped the book.

When I went to remove the drm, I got an error message saying this was not an Adept file. When i opened the book in ADE, it only showed the first 18 pages, the same as when I initially used ineptepub. So something is obviously happening in the unzip and rezip process.
Could this be a new block against removing DRM, or am I doing or not doing something.
Thanks

pdurrant
12-26-2010, 08:24 AM
There are certainly some problems with the zip structure of some epub books.

That simply unzipping and rezipping causes a problem in ADE does suggest that there's some problem in this book's zip structure that might also be causing problems in the dedrm process.

Hello,
I hope this is the proper forum for the questions I have.

I bought and downloaded an epub book with Adobe DRM. I wanted to read it on my iPad and used ineptepub to strip the drm. It only returned the first 18 pages of the book, the rest were blank.

i used several versions of ineptkey and ineptepub and got the same result.
I then made a copy and using your scripts unzipped and then rezipped the book.

When I went to remove the drm, I got an error message saying this was not an Adept file. When i opened the book in ADE, it only showed the first 18 pages, the same as when I initially used ineptepub. So something is obviously happening in the unzip and rezip process.
Could this be a new block against removing DRM, or am I doing or not doing something.
Thanks

James_Wilde
12-26-2010, 12:07 PM
You're the man, Paul. Thanks.

pdurrant
12-26-2010, 12:32 PM
There are certainly some problems with the zip structure of some epub books.

That simply unzipping and rezipping causes a problem in ADE does suggest that there's some problem in this book's zip structure that might also be causing problems in the dedrm process.

It turns out that this is a known problem to do with non-ascii characters in file names, and is a bug in the ineptepub script. I think a fix should be out soonish.

Meanwhile, it is possible to work around the problem by unzipping the epub in question, and changing the file names and the references to the files in the opf file and the encryption.xml file

Jim Lester
01-05-2011, 01:19 PM
I've automated this a bit by adding the following to my .bash_profile


#Create ePub file from exploded directory at CWD
# USAGE: zipub Path (shouldn't be under CWD) ie do zipub ../test.epub
zipub () {
zip -X0 $1 mimetype
zip -rDX9 $1 * -x "*.DS_Store" -x mimetype
}

ronmartinez
02-05-2011, 08:15 PM
Hi there
Hope somebody can help with this - I've been using ePub zip for a while and it's been a fantastic saviour, but suddenly it doesn't seem to work any more. When I try to zip my folder into epub I get an error message: "Can't make <<class ctnr>> of item 1 {alias "Macintosh HD:Users:Mini25:Desktop:nameofmyfolder:"} into type text." I can OK this or press an "Edit" button, which opens the Apple Script Editor (beyond me!)
Not sure what changed on my system or in my epub - it just seems to have changed from one day to the next. Any ideas?
Thanks very much
Michael
Hi! Not sure if you've gotten this sorted out. I had the same experience with this wonderfully useful script when I tried to use it on a different machine (Mac Pro, fine, Macbook, exact same error). Odd.

I was able to work around it with a hack to the Applescript. It's not a fix, just a way to keep working. You're going to delete the troublesome code and hardwire the result it's attempting to produce - a path (i.e., location on your hard drive) to place the finished ePub file.

The steps:

- Open the script in the Applescript Editor
- Run the script from the Editor, using the green run button, and select your ePub folder
- It should fail with error message once you have selected the folder
- Note at the bottom of the Editor there is an Event Log. You should see something like this:

error "Cant make class ctnr of alias \"home:Users:ronmartinez:a_yo_iBookC:\" into type text." number -1700 from class ctnr of alias "home:Users:ronmartinez:a_yo_iBookC:" to text

(The error apparently has something to do with the attempt to re-type the alias so it can be used in a variable. Needs some investigation and puzzling out, but this is happening in the 5th line of the script:

set ePubParent to (container of ePubFolder) as text

The workaround: hardwire the ePubParent variable. This will be the location your newly created ePub will be placed in. To do the hardwiring, you'll put a properly formatted path into the variable. I just used the same folder the ePub is in, but you can use another.)

- Note the correct form of the path in the second line of your error message in the Event Log. In my example:

"home:Users:ronmartinez:a_yo_iBookC:"

- Copy that string of text, including the quotes.
- Replace the troublesome line 5 with a line of text that says the following:

set ePubParent to "home:Users:ronmartinez:a_yo_iBookC:"

Of course, using your own path, and not my example path!

- Save As the script with a new name.
- Run the script
- It should work, and deposit the finished ePub at the destination indicated by the path. Note that you can use any destination folder on your hard drive volume, as long as the proper format is used.

Hopefully this helps. Back up your work before you do anything, natch. But should be pretty innocuous, and hopefully provides the OP with some clues as to the bug. (And thank you for this script, again!).

- Ron

MichaelGray
02-11-2011, 06:49 AM
Thanks Ron
I've slightly lost track of what happened, but as it's working again now and I can't remember what (if anything) I ended up doing to fix it (maybe I downloaded anew?) Perhaps it was just having a bad day. It's a great script I use a lot despite the odd hiccup –*thanks for you reply though!
Michael

Fern
02-12-2011, 01:17 PM
Thanks a lot pdurrant for the little app! It works beautifully!

Now, just out of curiosity (and because I'm interested in learning the nuts and bolts of the epub creation process), if I were to do in Terminal what your app does for me, which commands wound I have to enter? The ones in the first post of this thread don't seem to work. Sorry, I'm a UNIX noob. I keep getting messages such as "name not matched: mimetype" or "zip error: Nothing to do!"

pdurrant
02-12-2011, 05:18 PM
Now, just out of curiosity (and because I'm interested in learning the nuts and bolts of the epub creation process), if I were to do in Terminal what your app does for me, which commands wound I have to enter? The ones in the first post of this thread don't seem to work. Sorry, I'm a UNIX noob. I keep getting messages such as "name not matched: mimetype" or "zip error: Nothing to do!"

If you use Script Editor to open the script up, you'll be able to see exactly what commands are needed and how they're issued. It's quite a bit of hassle to issue them manually, especially as you need to escape path and file names that contain spaces and other awkward characters.

Fern
02-13-2011, 06:15 AM
If you use Script Editor to open the script up, you'll be able to see exactly what commands are needed and how they're issued.

Thanks for the tip pdurrant. Just shows I have still a lot to learn before I can mess around in Terminal. Great stuff! :thumbsup:

noteon
04-07-2011, 05:53 PM
Evening!

Thanks for making these scripts available. I've got a head-scratcher with ePub Zip that I'm hoping someone recognizes. I've unzipped an ePub with ePub Unzip, did a GREP alteration of some div tags in Text Wranger, and when I try to zip it back up, I get this:

zip warning: name not matched: mimetype
zip error: Nothing to do! (/Users/keithsnyder/Desktop/OEBPS.epub)

I'm certain I didn't alter anything but the div tags; what else could be causing this?

Thanks!

(MacOS 10.5.8, Intel Core 2 Duo)

EDIT: I'm an idiot. I was trying to zip the contents of the folder instead of the folder itself. Never mind...

dejiridoo
08-09-2011, 04:33 PM
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.

MignonK
08-31-2011, 07:55 AM
It is a great little tool, thank you.
And my rezipped ePub is working in the various readers I've been working with (Bookworm, Calibre, Ibis) but is now crashing Adobe Digital Editions (the original ePub file doesn't do that). Wondering if anyone else is experiencing this and what the problem may be.

pdurrant
08-31-2011, 01:41 PM
It is a great little tool, thank you.
And my rezipped ePub is working in the various readers I've been working with (Bookworm, Calibre, Ibis) but is now crashing Adobe Digital Editions (the original ePub file doesn't do that). Wondering if anyone else is experiencing this and what the problem may be.

The problem is probably in one of the bits you changed. So look there first. (It's probably also worth checking that the new version passed epubcheck, not that passing or failing epubcheck actually indicates whether any particular renderer will render it well.)

deb248211
09-18-2011, 10:59 AM
Thank you so much for the Applescript - I agree with David Derrico - you definitely rock super, super hard!

I'd spent the morning trying various zip commands, resulting in failed epubs, but now all is well. You are a star!

creativeshark
11-21-2011, 07:13 PM
I downloaded the zip 1.02 script app, but I've not yet found the unzip 1.0 script app... I've been watching the training videos on Lynda.com but don't have access to the exercise files and scripts and they recommend this site! Can someone please point me to the download link... ty so much in advance!

ATDrake
11-21-2011, 07:43 PM
I downloaded the zip 1.02 script app, but I've not yet found the unzip 1.0 script app...

You don't need an special unzip script. ePubs are just ordinary zip files, arranged in a certain way. You can unzip them using your regular unzip tool ("unzip" in the Terminal, or just add a .zip extension to the filename and double-click in the Finder).

Hope this helps, and welcome to MobileRead!

danrodney
11-22-2011, 01:18 AM
You don't need an special unzip script. ePubs are just ordinary zip files, arranged in a certain way. You can unzip them using your regular unzip tool ("unzip" in the Terminal, or just add a .zip extension to the filename and double-click in the Finder).

Hope this helps, and welcome to MobileRead!

The Finder doesn't always properly unzip scripts, and it's tedious renaming files or using the Terminal. I wrote the unzip script to make it faster and it always works. So to answer the question of where to download the unzip script. It's here (on page 2 of this thread):
http://www.mobileread.com/forums/showpost.php?p=1183274&postcount=19

Bretperry
01-11-2012, 09:44 PM
danrodney,,

Love this script. On a Mac, and thought I was going to have to buy Oxygen ($$$) just to fix epubs.

This does all I need for now!

Even better, it works great with InDesign CS5 .idml files (under the hood, a flavor of epub).

Do you mind if I adapt it to make a script that fixes "stuck" unused colors in InDesign (you save as .idml, edit the graphics file and re-open)?

Shall I credit you in the scripts header, want a link to this or just your name?

danrodney
01-12-2012, 01:27 AM
Do you mind if I adapt it to make a script that fixes "stuck" unused colors in InDesign (you save as .idml, edit the graphics file and re-open)?


Just out of curiosity, what will you do to the script? For stuck colors I simply export a .idml and re-open it. Then I can delete the stuck colors in InDesign. I'm not sure why a script would be needed.

But feel free to edit the script. There's already a credit comment at the top. Just add a new comment saying you made xxx edits.

Bretperry
01-13-2012, 03:30 AM
Just out of curiosity, what will you do to the script? For stuck colors I simply export a .idml and re-open it. Then I can delete the stuck colors in InDesign. I'm not sure why a script would be needed.

But feel free to edit the script. There's already a credit comment at the top. Just add a new comment saying you made xxx edits.

Thanks! Just exporting/opening idml doesn't always work, only about 1/2 the time for us. Making a frame with bad color fill, exporting page as PDF, importing that pdf, then deleting it works more often but not always.

Now with ePub unzip/zip I can change the "removable false" attribute of the color in the graphics xml file to "true", rezip and that works so far every time.

My script will be for my 40 users workgroup and other designers and art directors who are not comfortable editing and stuffing epubs and xml (what's all this scary code??)

We use spot colors extensively in InDesign bad swatches get replicated as docs are copied and re-purposed constantly. So now we have hundreds of current docs with stuck unused color swatches -- and soon an easy way to fix them without asking me to edit xml.

The user will find a bad color, run script choosing color in pop-up, go get a latte and return with a milk mustache to find the color long gone in the "same" doc and the working files cleaned.

I'll also make it find the unused but locked colors itself and fix batches. I don't see a swatch's "locked" info in ID's Applescript properties, but it can be found in the unzipped idml files, cool.

barncat
03-09-2012, 04:48 PM
Oh, woe is me. All I have done on this forum is whine. I downloaded the app. I dragged my epub to it. Nothing happened. I tried dclicking the app icon, got the dialgue, navigated to the epub. Nothing. This dang epub validates without a wince. I, myself, do not seem to validate at all.

pdurrant
03-09-2012, 07:53 PM
Oh, woe is me. All I have done on this forum is whine. I downloaded the app. I dragged my epub to it. Nothing happened. I tried dclicking the app icon, got the dialgue, navigated to the epub. Nothing. This dang epub validates without a wince. I, myself, do not seem to validate at all.

This AppleScript takes a folder and converts it to an ePub. It does nothing to an already zipped ePub.

barncat
03-11-2012, 02:26 PM
Hmm. I see. I had just finished a course with Anne-Marie in which she sent me to download quite a good script that unzipped and zipped epubs, downloadable from someone on Mobile Read. This is the only one I could find. I should have read more closely. I do love your portrait, by the way.

pdurrant
03-11-2012, 06:39 PM
Hmm. I see. I had just finished a course with Anne-Marie in which she sent me to download quite a good script that unzipped and zipped epubs, downloadable from someone on Mobile Read. This is the only one I could find. I should have read more closely. I do love your portrait, by the way.

Oh, I see what's happened. Someone else has done such a script and posted it in this thread here (http://www.mobileread.com/forums/showpost.php?p=1183274&postcount=19).

I haven't bothered to try it out, as I'm currently happy with my separate zip/unzip applescripts.

amarie0
05-13-2012, 06:33 PM
Hmm. I don't know of a script that does both the zipping and unzipping. I think the poseter may have misunderstood. This was the thread I sent people to (and still do during training and workshops). Paul, that post is in the first couple pages of this thread, I believe, and is (your) two separate scripts in one .zip file. Do you have a site where users could make donations to your cause? :D Seriously, I'd love to send them there.

amarie0
05-13-2012, 06:37 PM
(By the way, this is Anne-Marie, author of the Lynda.com videos who keeps sending people here LOL).

me too
07-06-2012, 02:25 AM
sir
i went through the thread you had suggested me,but its too far for a beginner i would like to explain the entire process i went through to create epub
as the first step i had created a folder on the desktop as maepub(is my epub)
then i had added mimetype file and modified it as per the tutorial
http://www.ibm.com/developerworks/xml/tutorials/x-epubtut/section3.html
(is that required that the content of mimetype should not exceed 20 bytes,i got it from a tutorial)
then i added 2 folders named it as META-INf and OEBPS
then added container.xml and modified as per the tutorial
then in OEBPS added content.html,content.opf,stylesheet.css,tittle.htm l,toc.ncx and an images folder with an image cover.png
after that i had compressd my maepub to get maepub.zip and changed its extension to .epub to get a result as maepub.epub
what i had explained in the post i had posted yesterday
i would like to appreciate paul for his commitment towards my post:thanks: but i want to learn it from from the baby tips
i would like to know step by step to create an epub ,will you be able to say me that whether i had created my folders correctly ,and please suggest me a step by step solution to get avoided from thoose validation problems i had ,i dont know whether iam out of good sense,but why dont you help me by putting a video for a step by step creation on youtube

it would be really helpful for thoose like me ,who really fight to sustain in this field as a beginner
this one is a humble request please go through it and give me a hand to get me my first ebook done,(i would like to remind you iam working on mac)
any kind of response would appreciated,please dont moke with me while reading this post
because iam only a beginner:help:

me too
07-06-2012, 02:31 AM
:thanks:
sir
i am only a beginner,so i cant follow the thread properly,will you be able to put a video on youtube so that i would be much more familiar for a beginner like me
please take my requedt into consider
hope for the best
:help:

me too
07-06-2012, 02:49 AM
thank you sir,
you had given me a reply for my question and apologies for posting it in introduction forum.
sir as i am a beginner i had tried my best but i could not make it to avoid thoose validation problems
sir first i had created a folder as maepub(name of my epub)addead mimetype ,META-inf and OEBPS and the required set of files as suggested in the tutorial
http://www.ibm.com/developerworks/xml/tutorials/x-epubtut/section3.html

i did upto this step and i dont know to go ahead,will you please suggest me a step by step resolution,plese specify if any downloads are reqiured.
i dont know whether it would be fair or not but iam compelled to ask you for a request to please add a video on you tube that will generate epub using handcode.
my hopes are dying idont know whether i will be able to create an epub or not
will you all join my hand to make this miracle happen
:help:

me too
07-06-2012, 03:01 AM
thank you sir
for sending me a link to follow,bu i could not follow may be because oflack of logic as a fresher.i have one request to you that will you please post a video on you tube to explain how to create an epub using hand coding ,putting stress on how to validate and to remove those validation errors occured for me.
i believe you will go through this and make a great decision to make my epub get finished
:thanks:
and
:help:

me too
07-06-2012, 06:39 AM
now i can zip it using the applescript suggested by paul, but when ihad validated i could find two errors,will you please suggest me a solutionResults

Detected version: EPUB 2.0

Results: The following problems were found in maepub.epub:

Type File Line Position Message
ERROR -1 -1 OPS/XHTML file OEBPS/title.html is missing
WARNING -1 -1 item (OEBPS/tittle.html) exists in the zip file, but is not declared in the OPF file
Validated using EpubCheck version 3.0b5-pre.

pdurrant
07-06-2012, 11:32 AM
now i can zip it using the applescript suggested by paul, but when ihad validated i could find two errors,will you please suggest me a solutionResults

Detected version: EPUB 2.0

Results: The following problems were found in maepub.epub:

Type File Line Position Message
ERROR -1 -1 OPS/XHTML file OEBPS/title.html is missing
WARNING -1 -1 item (OEBPS/tittle.html) exists in the zip file, but is not declared in the OPF file
Validated using EpubCheck version 3.0b5-pre.


I'm glad to hear you've managed to use the AppleScript successfully. Now you just need to read the error messages you're getting carefully.

The ERROR and WARNING you've got are related. Perhaps if I highlight some bits you'll see what's wrong.


ERROR -1 -1 OPS/XHTML file OEBPS/title.html is missing
WARNING -1 -1 item (OEBPS/tittle.html) exists in the zip file, but is not declared in the OPF file

me too
07-09-2012, 01:53 AM
i got it ,thanks a lot

pdurrant
10-15-2012, 08:24 AM
The ePub Zip AppleScript application is now the ePub Zip/Unzip AppleScript application!

A shiny new version of the application is available in the first post of this thread (http://www.mobileread.com/forums/showthread.php?p=581649#post581649).

Bug reports, feedback, additional translations are all welcome.

PageLab
10-16-2012, 09:03 AM
Thanks for this!

amarie0
10-19-2012, 11:07 AM
Paul, this is fantastic. Thank you! And thanks for updating the first post too. :D I keep sending people over here in my training videos and seminars, so this keeps them up to date, too!

AM

Aerys
10-22-2012, 01:55 AM
thanks!

pdurrant
10-22-2012, 01:34 PM
Just uploaded version 2.0.1 with German translation by shorshe added.

danrodney
10-24-2012, 06:43 PM
You know how iTunes adds an iTunesMetadata.plist in the root directory of the ePub file when dragging an ePub onto iTunes? Sometimes I unzip an ePub to find that nasty file (which invalidates your ePub).

If this Zip-Unzip script excludes .DS_Store files, how about it also exclude the iTunesMetadata.plist file? That way if it ever exists, you know it will be removed when rezipping. Could be nice, right?

pdurrant
10-24-2012, 07:22 PM
You know how iTunes adds an iTunesMetadata.plist in the root directory of the ePub file when dragging an ePub onto iTunes? Sometimes I unzip an ePub to find that nasty file (which invalidates your ePub).

If this Zip-Unzip script excludes .DS_Store files, how about it also exclude the iTunesMetadata.plist file? That way if it ever exists, you know it will be removed when rezipping. Could be nice, right?

I'm not sure I want to go that route myself. There may be people who want their iTunesMetadata.plist kept.

However, you could do quite easily for your copy. Open the script with AppleScript Editor, find the line containing

-x mimetype

change that bit to

-x mimetype -x iTunesMetadata.plist

and save. (Make sure you don't delete the " either side, or the space before the first -x)

pdurrant
11-02-2012, 06:13 AM
Just uploaded version 2.1. Now, when unzipping an ePub, the script first makes sure that there aren't any problems with the zip structure of the ePub.

pdurrant
11-02-2012, 09:39 AM
Just uploaded version 2.1.1. Now with a Portugese translation by PageLab.

More translations (or improvements to existing translations) are most welcome.

JGSTYLE
07-17-2013, 12:30 PM
Thanks for this, I've been using it successfully for over a year now.

I just ran into an issue, and I'm not sure if there's anything ePub Zip can do about it.

When I was submitting my epub file to Smashwords Direct, I received this error:

The book file you uploaded is in a format we do not support, or it has a filename extension we do not recognize. Your file appears to be a "application/zip" file, and has a ".epub" filename extension.

I never have this issue with Apple, Lulu, or Amazon.

The epub has a mimetype file which has the "application/epub+zip" line in it, but Smashwords doesn't acknowledge this.

Has anyone seen this and figured out a solution? Or does anyone have any ideas?

Jellby
07-17-2013, 12:44 PM
Is that "mimetype" file the first in the archive and is it uncompressed?

JGSTYLE
07-17-2013, 12:49 PM
The mimetype file is uncompressed as far as I can tell. It's in the root directory next to the "META-INF" and "OEBPS" directories.

pdurrant
07-17-2013, 04:28 PM
When I was submitting my epub file to Smashwords Direct, I received this error:



Have you successfully submitted to Smashwords before? I know they used to only accept Word/RTF files. While I think I heard something about them accepting ePubs recently, I'm not sure if that's out of beta yet.

In short: Are you sure the bit of Smashwords you uploaded to will accept an ePub?

JGSTYLE
07-17-2013, 06:41 PM
Have you successfully submitted to Smashwords before? I know they used to only accept Word/RTF files. While I think I heard something about them accepting ePubs recently, I'm not sure if that's out of beta yet.

In short: Are you sure the bit of Smashwords you uploaded to will accept an ePub?

Hi there, actually this is the first time I've ever uploaded to Smashwords because they previously only took the Words files.

Smashwords does now accept epubs as seen here:

https://www.smashwords.com/swdirect

The caveat being that they won't then reformat your file to all the other ones they usually do.

So far it's not a banner experience. They same epub that validates and works on every other service is rejected.

Like I said originally, I highly doubt this is the fault of ePub Zip, but I was hoping you or someone might know of a way to circumvent this error. I've been trying to find a way to manually adjust the mime type of the file, but no dice so far...

DaleDe
07-17-2013, 10:50 PM
The mimetype file is uncompressed as far as I can tell. It's in the root directory next to the "META-INF" and "OEBPS" directories.

That doesn't matter.

In windows open a cmd window and cd to wherever your ePub file is.
on the command line enter: type <filename> where filename is the name of your ePub file. Does it look like:
PK♥♦
yY8r╠▬ ▬ mimetypeapplication/epub+zip
PK♥♦
Ignore the leading garbage characters on the second line. The second PK may appear just after the mimetype info instead of on a different line. Ignore anything after the second PK.

If it does not then the ePub is not built correctly.

Dale

JGSTYLE
07-17-2013, 11:07 PM
Hi Dale,

Thanks for your help. I did as directed and this output was returned:

W:\Documents\epub>type "\\.psf\Home\Documents\epub\The Cold Elf.epub"
PK♥♦
`▄6oa, mimetypeapplication/epub+zipPK♥♦ ]π6
g╚╙ ▬ META-INF/container.xmlU┴
┬0►D∩*►*m⌠


looks like I've got an extra line there...is that a possible issue?

DaleDe
07-18-2013, 02:17 AM
No, that looks fine. It is exactly what you should expect. The additional line doesn't matter. Only the 2 PK's with the mimetype in between matters.

JGSTYLE
07-18-2013, 12:20 PM
Ok, thanks. Well, it's obvious the problem is with Smashwords then.

I had contacted them earlier but still have not heard back.

After Googling some more, it seems that the browser may be reporting the mimetype wrong at upload time -but still only with their service.

The funny thing is one of the recommended solutions was to upload using Chrome, except that I was already using Chrome, so that's already tried and failed.

Just for closure I'll report back if I get any decent workaround or resolution from Smashwords.

amyg
07-18-2013, 08:37 PM
For what it's worth, I have submitted epub books to Smashwords that I made using this applescript and they were accepted.

Is it possible Apple iTunes added its iTunesMetadata.plist? That might cause problems with Smashwords.

JGSTYLE
07-18-2013, 08:56 PM
For what it's worth, I have submitted epub books to Smashwords that I made using this applescript and they were accepted.

Is it possible Apple iTunes added its iTunesMetadata.plist? That might cause problems with Smashwords.

Yeah, it's definitely not this script. I was grasping at straws, apparently. The epubs I create are accepted everywhere else. I'm just going to have to backup and go through my process of building the files to see where I could be going wrong.

Smashwords responded to me today but all they will say is to make sure it's an epub 2, as they don't accept epub 3 yet.

I don't want to hijack this thread any longer since my issue is not with this script, but thanks to all who made suggestions, I appreciate it.

LLV
08-03-2013, 05:40 PM
First I wanted to thank pdurrant so much for writing the EPUB Zip script!

However I disagree that unzipping is so easy. I've had some EPUBs that do not properly unzip with the Finder's native unzipper (and renaming your files is a pain if you need to do it a lot). Using pdurrant's code as a reference, I went ahead and made an UnZip app that uses the terminal command which I find more reliable.

While I was at it I updated the EPUB Zip 1.0.2.app to remove the confirmation dialog at the end (to speed things up) and make the dialog messages more consistent with the UnZipper I created.

Here's the new version for all to enjoy. It contains:
EPUB UnZip 1.0.app
EPUB Zip 1.0.3.app

Thanks again for your contribution.
Dan

Dan,

I would like to try the ePub Unzip and the Epub Zip, where can I get them?

Thanks!

pdurrant
08-03-2013, 06:17 PM
Dan,

I would like to try the ePub Unzip and the Epub Zip, where can I get them?

Thanks!

Dan posted them in his very next post to the one you quoted. But since he posted them I enhanced my AppleScript to do both zipping and unzipping.

LLV
08-03-2013, 06:21 PM
Dan posted them in his very next post to the one you quoted. But since he posted them I enhanced my AppleScript to do both zipping and unzipping.

Hi, That is great! Where can I find them?

Thanks!

pdurrant
08-03-2013, 06:27 PM
Hi, That is great! Where can I find them?

Thanks!

Dan's scripts. (http://www.mobileread.com/forums/attachment.php?attachmentid=60233&d=1288118871)

My script. (http://www.mobileread.com/forums/attachment.php?attachmentid=95318&d=1351859908)

(From this post (http://www.mobileread.com/forums/showpost.php?p=1183274&postcount=19) and this post (http://www.mobileread.com/forums/showpost.php?p=581649&postcount=1) respectively.)

LLV
08-03-2013, 06:29 PM
Hi, That is great! Where can I find them?

Thanks!

I just found them. Thanks!

LLV
08-03-2013, 06:31 PM
Dan's scripts. (http://www.mobileread.com/forums/attachment.php?attachmentid=60233&d=1288118871)

My script. (http://www.mobileread.com/forums/attachment.php?attachmentid=95318&d=1351859908)

(From this post (http://www.mobileread.com/forums/showpost.php?p=1183274&postcount=19) and this post (http://www.mobileread.com/forums/showpost.php?p=581649&postcount=1) respectively.)



Hi, You are just wonderful! Thanks so much!

stuzog
10-17-2013, 04:02 PM
Today, when dropping a complete EPUB folder onto the ePub Zip/Unzip 2.1.1 icon (OS X 10.8.5) it started copying the epub folder before compressing it into an epub file. As a result, I get original, original.epub + copy1, copy1.epub generated, instead of original, (new)original.epub, and so on.

What's happening? Is this just a bug in 2.1.1 or is it something on my Mac?

stuzog
10-17-2013, 04:13 PM
OK, a restart cured that condition!

Wonderment
11-19-2013, 01:27 PM
Thanks pdurrant- this still continues to help.

Bonnie_27
04-02-2014, 02:16 PM
Dan's scripts. (http://www.mobileread.com/forums/attachment.php?attachmentid=60233&d=1288118871)

My script. (http://www.mobileread.com/forums/attachment.php?attachmentid=95318&d=1351859908)

(From this post (http://www.mobileread.com/forums/showpost.php?p=1183274&postcount=19) and this post (http://www.mobileread.com/forums/showpost.php?p=581649&postcount=1) respectively.)

hi I just came across this I know its a old post but I was wondering if this works for Windows as well I have version 8

pdurrant
04-02-2014, 03:44 PM
hi I just came across this I know its a old post but I was wondering if this works for Windows as well I have version 8

Being AppleScripts, which are specific to Mac OS, they won't work on Windows.

Bonnie_27
04-02-2014, 04:02 PM
Being AppleScripts, which are specific to Mac OS, they won't work on Windows.

do you know any Windows ones

saoir
08-29-2014, 04:16 PM
I have an ePub output from Scrivener that I want to add a title and copyright page to. I plan to use Dreamweaver.
Q: Does the ePub get structured (for reading by Kindle for example) based on the alphabetical order of the individual .xhtml files zipped into it ?

DaleDe
08-29-2014, 04:20 PM
I have an ePub output from Scrivener that I want to add a title and copyright page to. I plan to use Dreamweaver.
Q: Does the ePub get structured (for reading by Kindle for example) based on the alphabetical order of the individual .xhtml files zipped into it ?

No it does not. It gets the reading order from the spine section in the OPF. Read about ePub in our wiki.

Dale

pdurrant
08-29-2014, 04:40 PM
I have an ePub output from Scrivener that I want to add a title and copyright page to. I plan to use Dreamweaver.
Q: Does the ePub get structured (for reading by Kindle for example) based on the alphabetical order of the individual .xhtml files zipped into it ?

You would be a lot better off using calibre.

saoir
08-29-2014, 09:41 PM
You would be a lot better off using calibre.

Ok .. I'll check that out. I've been using calibre for a while with my Kindle.

Tks