I've many epub as folders need to convert it to .epub compressed so i created bash script to that ..which are compress the epub folder to zip then rename it to .epub using 7-zip

btw i was try to use zip instead of 7-zip but i face issue with some files are content arabic character like

   السوق في الغرب.xhtml

after compressed using zip i got the file has been renamed to something unreadable like


Causing corrupt the epub file therefor I've use 7zip and seems it's fine no issue but I've small issue before in zip i was use like that

zip -X file.zip mimetype
zip -rg file.zip * -x mimetype
mv file.zip file.epub

and working except the above issue , now i try to do the same with 7z but i face issue with exclude the mimetype i got and error Error: Incorrect command line

here my script

for i in *; do
7z a -tzip $i.zip mimetype
7z a -tzip $i.zip * -x!mimetype
rename *.zip *.epub

Thank you in advance


You should escape the exclamation mark because of the shell, like this:

7z a -tzip $i.zip * -x\!mimetype

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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