I have a relatively large epub file with a toc where I am interested in only a fraction of the pages. (More specifically it is a complete spell directory for an rpg and I want to keep only the spells my character learned or can learn).

Is there any tool that easily allows deleting pages and strips the deleted pages from the table of contents and other links?

Until now the easiest way I can see is to convert epub to html with calibre and then use a huge bash (sed) script to modify the links between all pages (this means a table of contents for every chapter and even links for page turning) in all of the html files.

Are there programs that is better at doing this?

Thank you very much!

  • Perhaps code.google.com/p/sigil
    – Dan D.
    Aug 16 '13 at 9:39
  • @DanD. I tried this one already. I can delete the pages/chapters, but only one by one and it always takes several minutes before new input can be made. Also modifying the TOC seems to be impossible. If I let it unchanged an error is thrown, when I choose an entry. A newly generated index is always empty. So generally this program may do the job, but in my case it fails.
    – Tim
    Aug 16 '13 at 10:47

After reading and trying for some time I found out, that any conversion to html makes things worse. Reading about how an epub is actually built, lead to the following steps:

  1. Unzip the epub file (it is a valid zip file just with a different suffix)
  2. Inside there there are all chapters as *.xhtml files and two important files content.opf and toc.ncx
  3. Using toc.ncx the unwanted xhtml files can be identified (delete the unwanted navPoint section afterwards)
  4. content.opf contains a manifest and a spine section.
  5. In the manifest section an id is assigned to each file. The order of these ids in the spine section is the order in which the chapter files occur in the book.
  6. Remove the corresponding line from the spine section and the chapter is gone.
  7. You can then remove the line from the manifest and delete the xhtml file. Everything works without this step, but it is just dead weight.
  8. Zip it again and change the suffix to epub.

These steps are scriptable well enough for me, so my problem is solved.

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.