How can I control the order of files in a ZIP archive?
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?
96 Answers
7-zip GUI version:
- extract
mimetypefrom EPUB file - delete
mimetypein EPUB file - rename
mimetypeto!mimetype - add
!mimetypeto EPUB file - rename
!mimetypetomimetypeinside 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 mimetypePut 7za.exe and repair.bat in the same directory and simply drag your EPUB file on repair.bat.
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#
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.
7The 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.
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 mimetypeTo 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!
1In 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.
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.
I had this same problem when working with EPUB-files.
On Windows 7 I fixed it with this strange trick where i made sure that I sorted all of the files that i was going to make in to a zip in a way that made mimetype the file on top (sorting them by size usually). Then I made sure that i marked all of the files from top to bottom with my cursor before sending them to a compressed (zip) folder (like this: ). After that I could change the name and filetype to whatever.epub.
However, after I upgraded to Windows 10 this trick did not work anymore. Luckily I have found another way. First you send the file you want at the top (mimetype) in the zip file to a compressed(zip) folder. Make sure it is only that file. Than I take the other files i want to zip (two folder in my case) mark them with the cursor and drag them up to the zip file i just created. Windows will then add the new files to the zip file, and keep the file you originally ziped on top.
1More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"