Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 11-17-2011, 03:01 PM   #1
kbrannen
Junior Member
kbrannen began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2011
Location: USA
Device: Android phone
Easy conversion with 1 chapter per file?

I have a number of books (articles) that are 1 chapter per file in HTML, 1 book per directory. I've been having trouble making Calibre easily change those to an epub doc. So help?

I eventually figured out that it works better when I put all the files into a zip file and try to add/convert that. I can get it better still if I create a toc.html much like in the user manual -- a bit of a pain but I can write a perl script to do that. (I don't know python.) I could concat all the files into a single file per book, but that has it's own drawbacks, unless that's the secret to making this process work (then I'll live with the drawbacks).

I was hoping that there was an easy way to tell Calibre to take all the files in "this directory" and create an epub. Is there such a command or plugin or whatever that someone can point me to? I didn't see anything like that in the user manual.

Also, how do you do the above from the command line? I have more of these dirs than I care to convert by hand, but the user manual doesn't give any hints that help (or else I can't find the right parts).

So, any pointers to docs, web pages, whatever, would be very helpful. I'm sure I can't be the first with this problem, but my searching has not found anything so far.

Thanks!
Kevin
kbrannen is offline   Reply With Quote
Old 11-17-2011, 03:04 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by kbrannen View Post
I have a number of books (articles) that are 1 chapter per file in HTML, 1 book per directory. I've been having trouble making Calibre easily change those to an epub doc. So help?

I eventually figured out that it works better when I put all the files into a zip file and try to add/convert that. I can get it better still if I create a toc.html much like in the user manual -- a bit of a pain but I can write a perl script to do that. (I don't know python.) I could concat all the files into a single file per book, but that has it's own drawbacks, unless that's the secret to making this process work (then I'll live with the drawbacks).

I was hoping that there was an easy way to tell Calibre to take all the files in "this directory" and create an epub. Is there such a command or plugin or whatever that someone can point me to? I didn't see anything like that in the user manual.

Also, how do you do the above from the command line? I have more of these dirs than I care to convert by hand, but the user manual doesn't give any hints that help (or else I can't find the right parts).

So, any pointers to docs, web pages, whatever, would be very helpful. I'm sure I can't be the first with this problem, but my searching has not found anything so far.

Thanks!
Kevin
The Calibre FAQ covers this exact problem: http://manual.calibre-ebook.com/faq....specific-order
theducks is offline   Reply With Quote
Advert
Old 11-17-2011, 03:32 PM   #3
kbrannen
Junior Member
kbrannen began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2011
Location: USA
Device: Android phone
Quote:
The Calibre FAQ covers this exact problem: http://manual.calibre-ebook.com/faq....specific-order
Err, yes, that was the part I was referencing when I mentioned creating a toc.html file. Maybe I need to be more specific in my question.

I have a number of dirs with files like: 01.html, 02.html, 03.html, etc. I'm looking for an easy way to use Calibre to take such a dir and convert it to an epub doc. I can create a toc.html file as mentioned in the FAQ. What I can't find is an example of how to use Calibre to do this conversion/creation from the command line (whether I need to create the toc.html or not). I need to expand beyond the GUI.

I need this to be easy and from the command line because I get new "books" all the time. I tend to download stuff then install it on my phone/tablet to read "offline", then delete it later. So my question is more about ease of use than how to make a doc look good. I almost don't even need a ToC, other than that helps to ensure that all the chapters are put in the correct order.

Amusing note, in my experimentation when I first started, without a toc.html file, Calibre created my epub with all the chapters in reverse order. Oops!

So, if there's a FAQ for this, please point it out.

Thanks!
kbrannen is offline   Reply With Quote
Old 11-17-2011, 04:23 PM   #4
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by kbrannen View Post
I have a number of dirs with files like: 01.html, 02.html, 03.html, etc. I'm looking for an easy way to use Calibre to take such a dir and convert it to an epub doc.
calibre isn't designed to do this. If you have a toc.html (often labeled index.html) then just drag that file to calibre, and it will create a zip file you can convert. Otherwise, build the toc file with Perl or Python. I haven't seen any threads on doing this.

Quote:
I can create a toc.html file as mentioned in the FAQ.
Once you have that, just add it, then convert it. Those steps can both be done with the CL tools.

Quote:
What I can't find is an example of how to use Calibre to do this conversion/creation from the command line (whether I need to create the toc.html or not). I need to expand beyond the GUI.
ebook-convert is the conversion command. calibredb add is the add command to build the zip file from the toc file. (I'm not sure if you can directly convert from the toc to epub - try it. Any other format that you can add can be directly converted.)

Quote:
Amusing note, in my experimentation when I first started, without a toc.html file, Calibre created my epub with all the chapters in reverse order. Oops!
This is odd. As far as I know, without a toc file, calibre would have made separate ebooks. It shouldn't have put them together reversed or otherwise.
Starson17 is offline   Reply With Quote
Old 11-17-2011, 04:36 PM   #5
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Note: the Index.html file needs to work from where it is located when passed to Calibre.
This means it will open each of the pieces correctly, and (Local)Images are shown properly.
Calibre will follow the Local links and src's and include them.
theducks is offline   Reply With Quote
Advert
Old 11-18-2011, 01:11 AM   #6
kbrannen
Junior Member
kbrannen began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2011
Location: USA
Device: Android phone
Ok, so it sounds like I should be able to do what I need with this index/toc file and handing that to "ebook-convert" and possibly also using "calibredb add". Let me try some experimentation along those lines. I found ebook-convert in the manual, but it really wasn't clear to me how I should use it for what I needed.

Quote:
Quote:
Amusing note, in my experimentation when I first started, without a toc.html file, Calibre created my epub with all the chapters in reverse order. Oops!
This is odd. As far as I know, without a toc file, calibre would have made separate ebooks. It shouldn't have put them together reversed or otherwise.
It did make a separate ebook for each chapter, at first. Noting that it could deal with zip files, I then tried "zip book.zip 1.html 2.html 3.html" and then added that book (which worked and showed 3 chapters in order), then did the convert to epub (all in the GUI). I was quite surprised to find the chapters out of order in the epub. That's when I went searching and found about the toc.html file and hence have gotten as far as I have.

Hopefully the info you've both shared will get me over the next hurdle. I see no reason Calibre can't solve this problem; it seems to have all the parts. I love perl and CPAN, but CPAN's Epub module looks hideously complex, hence my desire to find something simpler.

I'll post something here if I can get it working. But this seems like a problem that many others should have too and a documented solution should be available -- somewhere.

Thanks!
Kevin
kbrannen is offline   Reply With Quote
Old 01-15-2012, 01:12 AM   #7
kbrannen
Junior Member
kbrannen began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Nov 2011
Location: USA
Device: Android phone
Lightbulb The prototype answer

For anyone else wanting to do something like this, here's a prototype program to do what I was after. I think there are 2 possible ways to create the EPUB file for a "format shift":

1. Concat all the chapters into 1 big file, then convert that.
2. Create a ToC file and use that to handle the chapters correctly.

Possibility #1 isn't impossible, but it's not always trivial to do either (having to figure out how to rip apart the files and then putting just the right pieces back together), and it produces fairly ugly files that don't have a ToC.

Once I figured out how OPF files work, I decided to use these to pursue #2. So for me, I download all the files for 1 story (from fanfiction.net in this case) into a directory. Part of my download process cleans up the files by removing SCRIPT tags and other garbage I don't want. Once that's done, I can go to that directory in my terminal window and run the attached file, or even write a small script file on the command line to do several directories in one go. The result is an EPUB file for each dir/story, that I can copy to my Android phone and use with FBreader, or copy to my Nook to read. Once read, I can delete it.

I hope this helps others...

Comments about the program are at the top of the file. The most important ones are:
* You must have perl and Calibre installed to make it work.
* This is run from a command line (no GUI). While I developed and tested it on Linux, it should work on Windows and Mac without too much trouble, assuming you have its dependencies installed.
* Run the program without any arguments to get a usage statement.
* There are a number of possible enhancements to this program to make it "better", but it's very useable as is.
* Oh, you're free to use this or give it others for personal usage.

Kevin
Attached Files
File Type: pl makeebook.pl (6.7 KB, 142 views)
kbrannen is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Losing Chapter function after conversion jasewell Conversion 17 02-21-2011 08:20 AM
Easy Instructions for Converting a File to Kindle? crutnacker Amazon Kindle 5 01-02-2010 07:48 AM


All times are GMT -4. The time now is 05:30 PM.


MobileRead.com is a privately owned, operated and funded community.