Help Merging Multiple Small Epubs into One Large Epub
#1  kazbates 02-16-2011, 11:02 AM
I am trying to find a way to merge a set of small emancipated epubs into one large epub. I have looked through Sigil but am confused as to how to copy contents from multiple files to include in one single file.

Previously, I created html files, copy and pasted the content into a MSWord doc file, and then loaded that into Book Designer to create my final product. Unfortunately, the option of directly creating an html from the original ebook is no longer viable since the new agency choke-hold is limiting download choices.

I have looked into epub to html conversion software but thought I would ask the great minds here at MR first.

Any suggestions?

#2  pholy 02-17-2011, 12:01 AM
It's a little hard to describe, but I think I know how I would go about it. You have to understand how epubs are put together, so let me know if you need to learn that bit too.

First I would unzip each book into its own directory, then, I would create a destination work directory. Put the mimetype file and the META-INF directory (with its container.xml file) in the work directory. Now your omnibus volume will need a single content.opf file and a single toc.ncx file, so create empty files for them in the work directory.

Here's where things will get tricky. For each book, create a directory in the work directory. Into the book directory, copy the font, image, css, and html files from the unzipped epub directory. Do not copy the content.opf and toc.ncx files into the book directory. Instead, use the contents of those file to create the new content.opf and toc.ncx file in the work directory.

The new content.opf file will have a new metadata section describing your omnibus, but the manifest and spine sections will be made by combining those sections from each of your books, remembering to add in the new book directory into each file's path.

The new toc.ncx file will also be made by combining the existing toc files, but you will probably want to make a two (or more) level table of contents. The outer level will be new, with an entry for each book, then between each of those entries you can put the entries from each book's toc.ncx file. By the way, in Windows, you would be using Notepad++ to create these files, not Notepad or Word. In Linux, I'd use vim or gedit.

Once all that's done, zip it up and see if it validates using FlightCrew; then fix the errors until it does...

Do you begin to see why Sigil doesn't do this for you automatically? Oh, and by the way, I haven't actually done this for any collection of books, so I'm sure I left out lots of details that will bite me the first time I try it. If anybody has other suggestions, feel free to toss them into the pot.

#3  kazbates 02-17-2011, 02:14 PM
Pholy, Thank you so much for responding! I was starting to think I had asked a really silly question and people were rolling their eyes at me. I will try to walk through the steps you gave me and see how far I can get. . .It might take me a couple of days, though.

#4  JimmX 02-24-2011, 09:19 PM
Actually, I wanted the same thing--so I made a program to do it.

I just released it today:
I've made a standalone, command-line interface python program that can
merge multiple epub books together into one, combining the authors and
table of contents. My motivation was to be able to combine a series
of stories together into one epub.

Roman Kirillov has graciously allowed me to put it in the
fanficdownloader source repository. You can find in the
fanficdownloader directory of the fanficdownloader hg repository, or
get it directly from:

You'll need python installed to use it, and you'll need to call it
from command line. An example invocation would be:

python -o SeriesName.epub -t "Series Name" story1.epub

I've tested it with epubs from my most common sources (Calibre, Sigil,
Baen Publishing,, Let me know if
you have problems with other sources.

This only works with non-DRM epub files (Nook and other readers).
mobi files (as used by Kindle) are a lot more complicated. I don't
have any plans to work with mobi.

#5  kazbates 02-25-2011, 08:43 AM
Jim, Thank you!!

I'm afraid my programming days are long over (I started with Cobol, PL1, and C before they added all the +'s ), so I had no hope of accomplishing this on my own.

I will make some test cases and let you know how it goes.

Thanks again.

#6  GeoffC 02-25-2011, 11:09 AM

Welcome to Mobileread ....

Do stay and join in with us .....

#7  konrad 02-25-2011, 07:56 PM
Hi Jim
Downloaded your but am having trouble getting it to work. I took 3 epubs , and your script , put them in a separate directory and ran the script ...didn`t get any errors but didn`t get a merged epub either.This is the command I used " E:\1> -o all.epub -t Series 1.epub 2.epub 3.epub " Is there something I am not doing correctly? I have ActivePython 27 installed on my machine and other python scripts are working .Any help would be appreciated. Thank you.

#8  konrad 02-26-2011, 12:17 PM
Hello again Jim
Found the problem with running the epubmerge script. It was something I was doing wrong. It is working great now.Thank you for coming up with this script was something I had been looking for.

#9  lebleaux 03-01-2011, 09:25 PM
Just attempted to use epubmerge with python26. Got this:

File "", line 293, in <module> main()
File "", line 255, in main newnav=navpoints[0].cloneNode(True)
Indexerror: list index of of range

The invocation command was:

python26 -o out.epub a.epub b.epub

Have used a number of combinations of parameters, all with the same result. I do get output which I can view in winrar and get to the text of the stories, but I can not open the output in Sigil.

Any ideas

#10  lebleaux 03-01-2011, 09:42 PM
Further info. I opened each epub in Sigil, saved them and then ran epubmerge. Worked without a problem .... I like it

  Next »  Last »  (1/2)
Today's Posts | Search this Thread | Login | Register