![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,627
Karma: 406616
Join Date: Dec 2008
Location: Northern Virginia
Device: SurfacePro, SurfaceBook 2
|
Help Merging Multiple Small Epubs into One Large Epub
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 |
Booklegger
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,801
Karma: 7999816
Join Date: Jun 2009
Location: Toronto, Ontario, Canada
Device: BeBook(1 & 2010), PEZ, PRS-505, Kobo BT, PRS-T1, Playbook, Kobo Touch
|
Making an onmibus out of epub files...
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. Last edited by pholy; 02-17-2011 at 12:02 AM. Reason: Separate the paragraphs |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,627
Karma: 406616
Join Date: Dec 2008
Location: Northern Virginia
Device: SurfacePro, SurfaceBook 2
|
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.
![]() ![]() |
![]() |
![]() |
![]() |
#4 | |
Junior Member
![]() ![]() ![]() Posts: 1
Karma: 286
Join Date: Feb 2011
Device: Nook
|
Actually, I wanted the same thing--so I made a program to do it.
I just released it today: Quote:
|
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,627
Karma: 406616
Join Date: Dec 2008
Location: Northern Virginia
Device: SurfacePro, SurfaceBook 2
|
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 ![]() I will make some test cases and let you know how it goes. Thanks again. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Chocolate Grasshopper ...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,599
Karma: 20821184
Join Date: Mar 2008
Location: Scotland
Device: Muse HD , Cybook Gen3 , Pocketbook 302 (Black) , Nexus 10: wife has PW
|
Jim
Welcome to Mobileread .... ![]() Do stay and join in with us ![]() |
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 18
Karma: 10
Join Date: Feb 2010
Device: none
|
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. |
![]() |
![]() |
![]() |
#8 |
Member
![]() Posts: 18
Karma: 10
Join Date: Feb 2010
Device: none
|
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. |
![]() |
![]() |
![]() |
#9 |
Member
![]() Posts: 10
Karma: 10
Join Date: Jul 2010
Device: none
|
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 |
![]() |
![]() |
![]() |
#10 |
Member
![]() Posts: 10
Karma: 10
Join Date: Jul 2010
Device: none
|
Further info. I opened each epub in Sigil, saved them and then ran epubmerge. Worked without a problem .... I like it
|
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Apr 2011
Device: Nook
|
Is this still teh best way to go?
I have teh exact same need to merge multiple ePubs into the chapters of a single ePub to consolidate files and am new to all this... is this recommendation (the script in the thread above using Active Python 2.7) still the best (i.e. easiest) way to go? Thanks!
|
![]() |
![]() |
![]() |
#12 |
W2E & ePub freak
![]() Posts: 38
Karma: 10
Join Date: May 2009
Device: cybook gen3 + boox60
|
The given example don't work with my epubs, it gives me this error:
Code:
output file: merge.epub Traceback (most recent call last): File "epubmerge.py", line 373, in <module> main(sys.argv[1:]) File "epubmerge.py", line 72, in main options.striptitletoc) File "epubmerge.py", line 177, in doMerge source=firstmetadom.getElementsByTagName("dc:source")[0].firstChild.data.encode("utf-8") IndexError: list index out of range |
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,627
Karma: 406616
Join Date: Dec 2008
Location: Northern Virginia
Device: SurfacePro, SurfaceBook 2
|
I have found that the script only works with certain types of epub files. First, the file must be drm-free. Secondly, it has only worked for me with files that I have Opened and Saved in Sigil.
|
![]() |
![]() |
![]() |
#14 |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Sep 2011
Device: QUMO Libra 2
|
![]()
Hi,
I've taken JimmX's python script, modified it a bit to remove chapters from original books and made executable with py2exe. I used it without any flags. As a result you get one epub file with all books merged and available in TOC, prefixed with number of the book (01. Title, 02. Title, etc.). Chapters of merged books are not included. I've also included modified script as an attachment. |
![]() |
![]() |
![]() |
#15 |
Media Bloke
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,381
Karma: 113956855
Join Date: Sep 2010
Location: NSW - Australia
Device: iOS
|
That python stuff goes over my head mate, but it sounds pretty cool. Welcome to MR. You just posted onto the end of and old thread which won't attract as much attention as if you start a new thread.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Merging ePubs question | jhempel24 | Sigil | 0 | 01-11-2011 01:39 AM |
Feature Request - Merging of ePubs | fcoulter | Sigil | 6 | 07-29-2010 05:29 PM |
Migrating, Merging and Multiple Calibre Folders | daffy4u | Calibre | 3 | 06-28-2010 04:53 AM |
Consolidating/merging multiple formats | flinx1 | Calibre | 1 | 05-06-2009 01:17 PM |
Merging multiple scribbles at one time | ragdoll | iRex | 3 | 07-30-2008 01:39 AM |