Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zip an epub using a batch file and 7zip

I created this batch file to compress my epub files into an epub.

It checks for an existing epub and deletes it.

It checks the current folder name and then simply creates a zip file with the same name. It then renames that .zip to a .epub

for %%a in (.) do set currentfolder=%%~na
del *.epub
7z a -tzip %currentfolder%.zip META-INF OPS mimetype
rename *.zip *.epub

However I do not pass validation with this epub file. http://validator.idpf.org/ gives me the following two errors that I need to fix.

  • Mimetype entry missing or not the first in archive
  • item (OPS/image/Thumbs.db) exists in the zip file, but is not declared in the OPF file

1.How do I force the mimetype file to be the first in the archive?

2.How do I remove this thumbs.db, I can see it in the archive but i don't see it in Explorer?

Thank you in advance

like image 645
Morne Avatar asked Oct 23 '25 15:10

Morne


1 Answers

Ferroao has the right idea, but it can be simplified:

cd "folder of epub content"

# add mimetype 1st
zip -0 -X ../file.epub mimetype

# add the rest
zip -9 -X -r -u ../file.epub *

The -u on the second command tells Zip to add only new/changed files, so it will skip mime type on the second pass.

like image 177
Snow Coil Avatar answered Oct 27 '25 03:10

Snow Coil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!