How can I control the order of files in a ZIP archive?
Solution 1:
7-zip GUI version:
- extract
mimetype
from EPUB file - delete
mimetype
in EPUB file - rename
mimetype
to!mimetype
- add
!mimetype
to EPUB file - rename
!mimetype
tomimetype
inside EPUB file
7-zip simple drag and drop version:
Go to 7-zip download page and download 7-Zip Extra: standalone console version, 7z DLL, Plugin for Far Manager
(doesn't work with stable 9.20, but works well with 9.38 beta and 15.06 beta). Extract 7za.exe
. Save code below as repair.bat
file:
7za x %1 mimetype -y
7za d %1 mimetype
move /y mimetype !mimetype
7za a %1 !mimetype
del /f !mimetype
7za rn %1 !mimetype mimetype
Put 7za.exe
and repair.bat
in the same directory and simply drag your EPUB file on repair.bat
.
Solution 2:
One way would be: Most archivers, and archive tools have the ability to append or add additional file items to the original archive. Create your archive with the items you want at the top , then add additional files items to that created archive. I know this works in windows own ZIP tools.
looks like the real answer is beyond me , here for C# https://stackoverflow.com/questions/5898787/creating-an-epub-file-with-a-zip-library
here for HTML (using 7z)
http://next.blurb.com/2011/02/17/how-to-make-an-ipad-photo-book/
specificly this part
2.Open the sample-photo-book folder, and copy the file mimetype into the (empty) archive first.
3.Now, copy the other folders (META-INF and OEBPS) into the archive.
http://idpf.org/epub/30/spec/epub30-ocf.html#physical-container-zip
The contents of the mimetype file must not contain any leading padding or whitespace, must not begin with the Unicode signature (or Byte Order Mark), and the case of the MIME type string must be exactly as presented above. The mimetype file additionally must be neither compressed nor encrypted, and there must not be an extra field in its ZIP header.
Solution 3:
Creating an EPUB requires a two step process, first add mimetype without any (!) compression, second add the other files/folders. So using 7z you could take the following commands:
7z a -mx=0 dummy.zip mimetype
To be able to use the wildcard * you should move the file mimetype to another folder and start the second step:
7z a -r dummy.zip *
After that rename the ZIP to EPUB and you're gone!
Solution 4:
In my experience, the simplest answer (for Windows, 7, 64-bit) is to use Window's built-in Zip functionality. Use the "Send To" to send the mimetype to a new zipped folder, then use 7Zip to add the META-INF and OEBPS to the new zip. That seems to always work in terms of sequencing the mimetype file first. I have not had success performing this operation solely with 7-zip. (This is for ePUBS, but it should work, for sequencing, in other areas as well.)
I hope this helps someone else.