Mobileread
Help Merging Multiple Small Epubs into One Large Epub
#1  kazbates 02-16-2011, 12:02 PM
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?
Reply 

#2  pholy 02-17-2011, 01: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.
Reply 

#3  kazbates 02-17-2011, 03: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.
Reply 

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

I just released it today:
Quote
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 epubmerge.py in the
fanficdownloader directory of the fanficdownloader hg repository, or
get it directly from:

http://fanficdownloader.googlecode.com/hg/fanficdownloader/epubmerge.py

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

python epubmerge.py -o SeriesName.epub -t "Series Name" story1.epub
story2.epub

I've tested it with epubs from my most common sources (Calibre, Sigil,
Baen Publishing, fanficauthors.net, tthfanfic.org). 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.
Jim
Reply 

#5  kazbates 02-25-2011, 09: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.
Reply 

#6  GeoffC 02-25-2011, 12:09 PM
Jim

Welcome to Mobileread ....



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

#7  konrad 02-25-2011, 08:56 PM
Hi Jim
Downloaded your epubmerge.py 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>epubmerge.py -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.
Reply 

#8  konrad 02-26-2011, 01: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 ...it was something I had been looking for.
Reply 

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

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


The invocation command was:

python26 epubmerge.py -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
Reply 

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

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