Answers.Body: <p>zip -X0 ../myEPUB.epub mimetype<br>
  zip -9 -r ../myEPUB.epub META-INF OEBPS</p>
  
  <p>another common error i was getting was extra characters in mimetype 'Mimetype file should only contain the string 'application/epub+zip' and should not be compressed'
  I found that my editor Geany was adding a newline when I saved the file and this caused an epubcheck error - a tweak in Geany's preferences fixed this error and epubcheck returned no errors</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-01T20:36:58.853Z
Answers.LastActivityDate: 2019-01-01T20:36:58.853Z
Answers.UserDisplayName: Jonathan O'Gorman
Answers.Body: <p>As the accepted answer states, the mimetype file should be stored uncompressed in the archive. For those looking for a programmatic way to validate and package an EPUB I recommend using the Java <a href="https://github.com/w3c/epubcheck" rel="nofollow noreferrer">EPUBCheck tool</a> by W3C. You can use it as a command line tool and as a Java library. The tool allows you to validate an expanded EPUB folder and save it as an EPUB compressed archive upon successful validation.</p>
  <p>Example command:</p>
  <pre><code>java -jar epubcheck.jar epub/ --mode exp --save
  </code></pre>
  <p>Read <a href="https://github.com/w3c/epubcheck/wiki/Running" rel="nofollow noreferrer">the wiki</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-09T06:52:38.527Z
Answers.Text: I got weird error `Mode required for non-epub files. Default version is 3.0.`. I got stuck on it a bit. But my stupid error was that I had there quotes: `java -jar epubcheck.jar "epub/ --mode exp --save"`. When I removed quotes it works like charm. Thanks.
Answers.UserDisplayName: Vit Bernatik
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-22T13:24:36.533Z
Answers.LastActivityDate: 2021-02-22T13:24:36.533Z
Answers.UserDisplayName: valentin
Answers.Body: <p>Here are the steps I used to force the &quot;mimetype&quot; file to be the first in the EPUB archive using 7-Zip in Windows:</p>
  <ol>
  <li><p>Make a copy of your EPUB (zip) file (e.g. MyBookCopy.epub), so to not damage your original EPUB file in case things go wrong.</p>
  </li>
  <li><p>Extract all of the files from MyBookCopy.epub into an empty folder (e.g. MyFolder)</p>
  </li>
  <li><p>Using the 7-zip UI, delete all the files in MyBookCopy.epub except the “mimetype” file</p>
  </li>
  <li><p>Using the 7-zip UI, rename the “mimetype” file to “##mimetype” (this will ensure it remains listed first under the covers)</p>
  </li>
  <li><p>Using the 7-zip UI, re-add all the other epub files in MyFolder into your EPUB file (i.e. drag &amp; drop all these files into the 7-zip window where your epub is open)</p>
  </li>
  <li><p>Using the 7-zip UI, rename the “##mimetype” file back to “mimetype” (this will not alter its actual order in the ZIP file, even if its order changes in the UI)</p>
  </li>
  </ol>
  <p>Note: At any time, you can verify the actual order of the files in your EPUB file by running this command in a command prompt window: 7z l -slt &quot;MyBookCopy.epub&quot; (in the resulting output, locate the entry for the “mimetype” file and check that its “offset” value is “0” which means it’s the first file stored in the EPUB file).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-02T00:47:07.800Z
Answers.LastActivityDate: 2021-02-02T00:47:07.800Z
Answers.UserDisplayName: Pi Da
Answers.Body: <p>7-zip sorts files by names</p>
  <ol>
  <li>rename mimetype to ##mimetype</li>
  <li>Add to archive... ##mimetype<br>
  Archive: book.zip<br>
  Archive format: zip<br>
  Compression level: Store<br>
  OK<br></li>
  <li>Add to archive... the other folders META_INF EPUB<br>
  Archive: book.zip<br>
  Archive format: zip<br>
  Compression level: Normal<br>
  OK<br></li>
  <li>Open archive... book.zip<br>
  rename: ##mimetype to mimetype<br>
  OK<br></li>
  <li>rename book.zip to book.epub<br></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-24T22:31:20.713Z
Answers.LastActivityDate: 2020-07-24T22:31:20.713Z
Answers.UserDisplayName: fstil
Answers.Body: <p>The trick is to SELECT the files in the order in which they are to be stacked. </p>
  
  <p>For Windows users, do the following: </p>
  
  <ol>
  <li>Go to the folder that contains your ePub files. </li>
  <li><kbd>CTRL</kbd>+<kbd>CLICK</kbd> to select your files in the following order: (a) mimetype, (b) META-INF
  folder, and then (c) OPS folder. </li>
  <li>With all three items are selected (in that order), RIGHT-CLICK, and then select <code>Send To &gt; Compressed (zipped) folder</code>. </li>
  <li>Change your .zip file type to .epub.  </li>
  <li>Run it through the ePub Validator to confirm the file.</li>
  </ol>
  
  <p>Good luck!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-17T06:10:09.723Z
Answers.Text: It would be useful to explain how do to get an option "Compressed (zipped) folder" in the "Send To" menu in the first place, as there are only options for messaging, email, burn to CD, backup and send via Bluetooth there.
Answers.UserDisplayName: Anthon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-02T23:29:30.410Z
Answers.Text: this doesn't work to get rid of the error message from epubchecker.
Answers.UserDisplayName: invalidusername
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-09-15T18:11:06.317Z
Answers.LastActivityDate: 2014-10-03T15:02:34.050Z
Answers.LastEditDate: 2014-10-03T15:02:34.050Z
Answers.UserDisplayName: John
Answers.Body: <p>I tried to pack first mimetype to 7-zip and then add rest. Like this:</p>
  <pre><code>&quot;C:\Program Files\7-Zip\7z.exe&quot; a -mx0 file.epub mimetype
  &quot;C:\Program Files\7-Zip\7z.exe&quot; a -mx0 file.epub ../v0/*
  </code></pre>
  <p>and it <strong>does not work with 7-zip</strong>.</p>
  <p>One option that worked for me was to download <code>Sigil</code> free ePub editor. Then you can pack folder with 7-zip and open in Sigil. Sigil will automatically repair the archive upon opening...</p>
  <p>Another option was to use <code>Total Commander</code> internal zip archiver.</p>
  <ol>
  <li>click <code>mimetype</code></li>
  <li>Click <code>Files-&gt;Pack (alt+F5)</code></li>
  <li>Right top corner set <code>compress rate</code> to <code>0</code></li>
  <li>click <code>ok</code> and it will create <code>mimetype.zip</code></li>
  </ol>
  <p>Then open that <code>mimetype.zip</code> archive in total commander and <code>copy (F5)</code> there rest files.
  In copy dialog set <code>compression level</code> back to <code>5</code>.</p>
  <p>Rename <code>mimetype.zip</code> to <code>yourName.epub</code> and you are done.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-08T18:31:52.527Z
Answers.LastActivityDate: 2024-07-09T06:54:11.837Z
Answers.LastEditDate: 2024-07-09T06:54:11.837Z
Answers.UserDisplayName: Vit Bernatik
Answers.Body: <p>This error can occur when the mimetype is compressed inside the epub zip file. What can be done is to create a zip file with only the mimetype file inside but with no compression. </p>
  
  <p>You can do that with 7-Zip setting the <code>Compression level</code> to <code>Store</code>. </p>
  
  <p>In Linux, you can also do that with the terminal command:</p>
  
  <pre><code>zip -0 file.epub mimetype
  </code></pre>
  
  <p>Then drag and drop the META-INF and OEBPS folders to the file.zip and change the extension to .epub, as usual. With the Linux terminal you can use this command line instead:</p>
  
  <pre><code>zip -9 -r file.epub META-INF OEBPS
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-02T23:27:28.940Z
Answers.Text: So how do you achieve this on Windows using 7Zip? I tried different settings and approaches and i'm still getting the same error message. Is there any other tool that somebody can recommend to use?
Answers.UserDisplayName: invalidusername
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-15T00:54:00.277Z
Answers.LastActivityDate: 2014-10-03T15:03:17.373Z
Answers.LastEditDate: 2014-10-03T15:03:17.373Z
Answers.UserDisplayName: Allan Veloso
Body: <p>I have an ePub that returns "mimetype entry missing or not the first in archive" error in epubcheck, even though the mimetype file is correctly placed.</p>
  
  <p>How to fix that?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-05T14:06:52.170Z
Comments.Text: How do you know it is correctly placed?
Comments.UserDisplayName: mmmmmm
Tags: <epub><epubcheck>
Title: epubcheck error: mimetype entry missing or not the first in archive
UserDisplayName: Allan Veloso
ThreadText: # epubcheck error: mimetype entry missing or not the first in archive
  
  (Asked by: username_0 on 2014-01-15)
  
  I have an ePub that returns "mimetype entry missing or not the first in archive" error in epubcheck, even though the mimetype file is correctly placed.
  
  How to fix that?
  
  **Tags:** epub, epubcheck
  
  > **Comments:**
  > **username_1**: How do you know it is correctly placed?  
  
  ---
  
  ## 7 answers
  
  ### Answer by username_0 on 2014-01-15. Score: 15 | Accepted answer
  
  This error can occur when the mimetype is compressed inside the epub zip file. What can be done is to create a zip file with only the mimetype file inside but with no compression. 
  You can do that with 7-Zip setting the Compression level to Store. 
  In Linux, you can also do that with the terminal command:
  zip -0 file.epub mimetype
  
  Then drag and drop the META-INF and OEBPS folders to the file.zip and change the extension to .epub, as usual. With the Linux terminal you can use this command line instead:
  zip -9 -r file.epub META-INF OEBPS
  
  > **Comments:**
  > **username_9**: So how do you achieve this on Windows using 7Zip? I tried different settings and approaches and i'm still getting the same error message. Is there any other tool that somebody can recommend to use?  
  
  ---
  
  ### Answer by username_2 on 2019-01-01. Score: 3
  
  zip -X0 ../myEPUB.epub mimetype  
  zip -9 -r ../myEPUB.epub META-INF OEBPS
  
  another common error i was getting was extra characters in mimetype 'Mimetype file should only contain the string 'application/epub+zip' and should not be compressed'
  I found that my editor Geany was adding a newline when I saved the file and this caused an epubcheck error - a tweak in Geany's preferences fixed this error and epubcheck returned no errors
  
  
  ---
  
  ### Answer by username_3 on 2021-02-22. Score: 2
  
  As the accepted answer states, the mimetype file should be stored uncompressed in the archive. For those looking for a programmatic way to validate and package an EPUB I recommend using the Java EPUBCheck tool by W3C. You can use it as a command line tool and as a Java library. The tool allows you to validate an expanded EPUB folder and save it as an EPUB compressed archive upon successful validation.
  Example command:
  java -jar epubcheck.jar epub/ --mode exp --save
  
  Read the wiki.
  
  > **Comments:**
  > **username_4**: I got weird error `Mode required for non-epub files. Default version is 3.0.`. I got stuck on it a bit. But my stupid error was that I had there quotes: `java -jar epubcheck.jar "epub/ --mode exp --save"`. When I removed quotes it works like charm. Thanks.  
  
  ---
  
  ### Answer by username_5 on 2021-02-02. Score: 1
  
  Here are the steps I used to force the "mimetype" file to be the first in the EPUB archive using 7-Zip in Windows:
  
  1. Make a copy of your EPUB (zip) file (e.g. MyBookCopy.epub), so to not damage your original EPUB file in case things go wrong.
  2. Extract all of the files from MyBookCopy.epub into an empty folder (e.g. MyFolder)
  3. Using the 7-zip UI, delete all the files in MyBookCopy.epub except the “mimetype” file
  4. Using the 7-zip UI, rename the “mimetype” file to “##mimetype” (this will ensure it remains listed first under the covers)
  5. Using the 7-zip UI, re-add all the other epub files in MyFolder into your EPUB file (i.e. drag & drop all these files into the 7-zip window where your epub is open)
  6. Using the 7-zip UI, rename the “##mimetype” file back to “mimetype” (this will not alter its actual order in the ZIP file, even if its order changes in the UI)
  
  Note: At any time, you can verify the actual order of the files in your EPUB file by running this command in a command prompt window: 7z l -slt "MyBookCopy.epub" (in the resulting output, locate the entry for the “mimetype” file and check that its “offset” value is “0” which means it’s the first file stored in the EPUB file).
  
  
  ---
  
  ### Answer by username_6 on 2020-07-24. Score: 1
  
  7-zip sorts files by names
  
  1. rename mimetype to ##mimetype
  2. Add to archive... ##mimetype  
     Archive: book.zip  
     Archive format: zip  
     Compression level: Store  
     OK
  3. Add to archive... the other folders META\_INF EPUB  
     Archive: book.zip  
     Archive format: zip  
     Compression level: Normal  
     OK
  4. Open archive... book.zip  
     rename: ##mimetype to mimetype  
     OK
  5. rename book.zip to book.epub
  
  
  ---
  
  ### Answer by username_7 on 2014-09-15. Score: 0
  
  The trick is to SELECT the files in the order in which they are to be stacked.
  
  For Windows users, do the following:
  
  1. Go to the folder that contains your ePub files.
  2. `CTRL`+`CLICK` to select your files in the following order: (a) mimetype, (b) META-INF
     folder, and then (c) OPS folder.
  3. With all three items are selected (in that order), RIGHT-CLICK, and then select `Send To > Compressed (zipped) folder`.
  4. Change your .zip file type to .epub.
  5. Run it through the ePub Validator to confirm the file.
  
  Good luck!
  
  > **Comments:**
  > **username_8**: It would be useful to explain how do to get an option "Compressed (zipped) folder" in the "Send To" menu in the first place, as there are only options for messaging, email, burn to CD, backup and send via Bluetooth there.  
  > **username_9**: this doesn't work to get rid of the error message from epubchecker.  
  
  ---
  
  ### Answer by username_4 on 2024-07-08. Score: 0
  
  I tried to pack first mimetype to 7-zip and then add rest. Like this:
  "C:\Program Files\7-Zip\7z.exe" a -mx0 file.epub mimetype
  "C:\Program Files\7-Zip\7z.exe" a -mx0 file.epub ../v0/*
  
  and it does not work with 7-zip.
  One option that worked for me was to download Sigil free ePub editor. Then you can pack folder with 7-zip and open in Sigil. Sigil will automatically repair the archive upon opening...
  Another option was to use Total Commander internal zip archiver.
  
  click mimetype
  Click Files->Pack (alt+F5)
  Right top corner set compress rate to 0
  click ok and it will create mimetype.zip
  
  Then open that mimetype.zip archive in total commander and copy (F5) there rest files.
  In copy dialog set compression level back to 5.
  Rename mimetype.zip to yourName.epub and you are done.
  
  
  ---
  
  