Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

There are times when it is necessary for the files in a ZIP archive to be in a specific order (for example, I'm currently creating EPUBs, which require that the first entry in the ZIP be the mimetype file). How can I do this on Windows?

I'm currently using 7-Zip as my archiver, but I don't see an option for controlling file order. Can this be done with 7-zip? If not, what options do I have?

share|improve this question
Adding them in the order that they need to be should do this. Try zipping the mimetype file first, then adding the other files to the zip as a second operation. –  Paul Feb 3 '12 at 0:25
@Paul — Surprisingly, that didn't work. :-/ –  Ben Blank Feb 3 '12 at 1:01
Is it LIFO maybe? Can you try adding mimetype last? You are testing against an epub reader right, rather than just unzipping? –  Paul Feb 3 '12 at 1:08
A application that requires the contents to be in a specific order is broken. –  psusi Feb 3 '12 at 3:52
Sheesh, the authors of the spec need taken out back and beaten with a clue-by-four. –  psusi Feb 3 '12 at 14:31

3 Answers 3

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# http://stackoverflow.com/questions/5898787/creating-an-epub-file-with-a-zip-library

here for HTML (using 7z)

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.


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.

share|improve this answer
I gave this a try in 7-zip (creating an archive with only mimetype, then adding the other files), but had no success. The mimetype data came first in the file, but the file table seems to be alphabetized. –  Ben Blank Feb 3 '12 at 1:04
@BenBlank Make sure you aren't checking this using a zip client - they will re-order in a way that suits humans, not necessarily what an epub reader will see. –  Paul Feb 3 '12 at 1:10
Presumably the problem is that 7-Zip likes to maintain it's directory in alpha order and then (necessarily) rewrites it when it closes the zip file. One could, in theory, fix this by editing the zip file with a hex editor or some sort of ad-hoc tool and rearranging the directory -- it's not particularly complicated. Editing would be simplified by including a dummy file that always sorts first. But then, of course, the technique in the above link should work too. –  Daniel R Hicks Feb 3 '12 at 1:22
I used 7z l filename.zip to list the contents of a zip, and they don't appear to be in any order (name, path, date, size...). So, using this command line may help determine the true order of the files in the zip. –  Scott McClenning Feb 3 '12 at 1:26
@Paul — I'm checking by opening the .epub in a text editor and examining the file table directly, so it looks like this approach simply isn't working for me. I'm going to take the Python hammer to the problem and see if that doesn't fix it. –  Ben Blank Feb 3 '12 at 2:35

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!

share|improve this answer
I have just tried this and I still get this error: Epubcheck Version 3.0.1 ERROR: C:/MYSELF/Books/1984---George-Orwell/1984---George-Orwell.epub: Mimetype entry missing or not the first in archive –  Tomáš Zato Oct 17 '14 at 22:24

Using winrar did the trick for me. I added the mimetype to a zip-archive (uncompressed!), then later added the remaining folders, regular compression.

This solution did not work with 7-zip for me, as it keeps reordering files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.