Skip to content

Instantly share code, notes, and snippets.

@spajak
Last active April 30, 2023 19:41
Show Gist options
  • Save spajak/9b8b8a46f7ebf8390f5943c3fe73195e to your computer and use it in GitHub Desktop.
Save spajak/9b8b8a46f7ebf8390f5943c3fe73195e to your computer and use it in GitHub Desktop.
Make epub using 7zip command line utility

Make epub archive using 7zip command line utility in PowerShell.

$source = ".\ebook"
$epub = ".\ebook.epub"

$source = (Resolve-Path $source -ErrorAction Stop).Path
Move-Item "${source}\mimetype" ".mimetype" -ErrorAction Stop
Remove-Item "$epub" -ErrorAction Ignore
& 7za a -mx0 "$epub" ".mimetype"
& 7za a -mx5 "$epub" "${source}\*"
& 7za rn "$epub" ".mimetype" "mimetype"
Move-Item ".mimetype" "${source}\mimetype"

For more robust script see build-epub.ps1
Or my Python script make-epub.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment