My EPUB Straight to the Point book explains how to use Terminal to zip EPUB files in two steps, first by adding the
mimetypefile with no compression, and second by adding the rest of the files with compression.
Unfortunately, there is an invisible file called DS_Store in every Mac OS folder that also gets added and that later generates validation errors (since it is present, but not declared in the manifest).
To remedy this problem, use the first zip line as usual:
zip -0Xq file.epub mimetype
(that is a number 0, not a letter O, and of course, use whatever filename for the EPUB file that you like)
But, to keep those pesky DS_Store files from being erroneously added to your EPUB file, you should modify the second line so it looks like this:
zip -Xr9Dq file.epub * -x *.DS_Store
which basically says, compress all the rest of the files and folders into the file.epub file, but omit DS_Store files, wherever they may be.
And I can't remember who tweeted my latest favorite shortcut, but it's a good one. In Terminal, use the up arrow to repeat an earlier command line. Then press Return to execute.
Finally, if you're on a PC, you should check out the folder2zip utility created by Gerald Schmidt and his colleagues at the Open University. To use it, type
folder2zip C:\path\to\my\epub\folder epub