3

Im looking for a way to take a book as an epub file and break it up into a series of smaller epub files for each chapter? I am aware of the other available options with Sigil and the Epubsplit plugin for calibre, but they both seem to work through a GUI, which precludes being able to run them over hundreds or thousands of files in a script.

Is there no way of doing this with one of the command line tools that calibre provides, such as ebook-convert, so that I can call something like

ebook-convert someBook.epub --splitIntoChapters

and get something like chapter1.epub, chapter2.epub, chapter3.epub... and so on in return?

1 Answer 1

0

Maybe an old perl library libebook-tools-perl?

man ebook(1p) has some examples, taking inspiration something like this could work:

ebook unpack mybook.pdb my_book
cd my_book
mkdir split
# split document by chapters somehow with sed/awk/perl/python
cd ..
for i in my_book/split/*.xhtml; do
    base=$(basename $i ".xhtml)
    echo "generate $base"
    ebook blank $base.opf --title "My Title" --author "My Name"
    cp $i .
    ebook adddoc $base.xhtml
done

ebook fix
ebook genepub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .