Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 08-18-2024, 11:40 AM   #1
vanceism7
Junior Member
vanceism7 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2024
Device: Pixel 4a
Create ebook using filesystem structure

Hello, I've been trying to create an ebook from a collection of html files and wondering if someone can help me out.

The basic story is that I have a collection of html files stored in my filesystem with this basic type of hierarchy:

Book

├── 1-Foo
│ ├── chapter-1.html
│ ├── chapter-2.html
│ └── chapter-3.html

├── 2-Bar
│ ├── chapter-1.html
│ └── chapter-2.html

├── 3-Baz
│ ├── chapter-1.html
│ ├── chapter-2.html
│ └── chapter-3.html

My question is, is there anyway to convert my collection of files sorted like above into an ebook in Calibre such that the TOC and ordering of the book follows this structure?

So far, I've tried creating an index.html file which references all of the above files in order, and also just zipping the book folder and loading it into Calibre - in either case, Calibre throws the chapters into a completely random order.

I've been reading the Calibre manual and they say it uses all kinds of complicated processes to determine the ordering and chapters of the book, but in my case, the work has already been done, it's just that Calibre doesn't understand it.

I'm fine with creating a TOC if need be, but I can't find any info on how to manually create a TOC file or how to tell Calibre to use that TOC if I created one.
I also don't want to edit the TOC using the book editor, my hope is to generate it using scripts since I can do this easily based off the filesystem structure of the files.

But if there's a way to have Calibre infer the structure and ordering of the book from the filesystem automatically, that would be ideal!

Any help anyone could provide here would be greatly appreciated! Thanks so much!
vanceism7 is offline   Reply With Quote
Old 08-18-2024, 12:02 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,514
Karma: 24495784
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://manual.calibre-ebook.com/faq...specific-order
kovidgoyal is offline   Reply With Quote
Advert
Old 08-18-2024, 01:30 PM   #3
vanceism7
Junior Member
vanceism7 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2024
Device: Pixel 4a
Sorry, so that was the first thing that I tried. Calibre seems to ignore the ordering of the html file and pulls in the chapters in a completely random order when I do that.

Ah sorry, just noticed the breadth-first ordering. I tried this with the CLI but was getting errors that my html files were ignored because they were binary files. But I just read theres an option to set it in the GUI - ill give it a try

Last edited by vanceism7; 08-18-2024 at 01:34 PM.
vanceism7 is offline   Reply With Quote
Old 08-18-2024, 01:39 PM   #4
vanceism7
Junior Member
vanceism7 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2024
Device: Pixel 4a
Ok, so even using breadth-first ordering still results in a totally random chapter ordering
vanceism7 is offline   Reply With Quote
Old 08-18-2024, 03:22 PM   #5
vanceism7
Junior Member
vanceism7 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2024
Device: Pixel 4a
Update:

Ok so, I atleast found a workaround. I wrote a script that traverses my book files in the order I want, and appends each one to a combined html file, and then I supply that file to `ebook-convert` and that will cause calibre to render the chapters in the correct ordering. Just FYI for anyone else looking for a cheap solution to this in the meantime
vanceism7 is offline   Reply With Quote
Advert
Old 08-18-2024, 04:00 PM   #6
slm
Fool
slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.
 
Posts: 419
Karma: 3585252
Join Date: Feb 2003
Device: Kindle: Voyage,PW1,KOA, Kobo: Clara Colour, Nook GLP, Pocketbook verse
Did you actually try creating an HTML "table of contents" file as indicated by the link and then asking Calibre to add that file?
slm is offline   Reply With Quote
Old 08-18-2024, 11:41 PM   #7
vanceism7
Junior Member
vanceism7 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2024
Device: Pixel 4a
Quote:
Originally Posted by slm View Post
Did you actually try creating an HTML "table of contents" file as indicated by the link and then asking Calibre to add that file?
Yea, as I said, that was actually the first thing I tried. I had a script that generated a file something akin to

```
<html>
<body>
<h1>Table of Contents</h1>
<ol>
<li><a href="1-Foo/chapter-1.html>chapter-1</a></li>
... Etc etc
</ol>
</body>
</html>
```

And then tried the other structure more similar to the one in the manual. It successfully pulls in all of the files but it puts all the chapters in random order. I tried that also using the breadth-first option but it also didn't make a difference.

I'm sure it's probably because the algorithm is trying to follow links in the html, and the html links are somewhat malformed as this is a bit of a strange project I'm working on. But as I said, I really don't need a sophisticated algorithm here, I just need it to include the files using the same ordering the filesystem is using.

It would be nice if there was some ability to just zip up a directory and it just traversed the files in the natural ordering, but that doesn't seem to work as things are now. Unless there's a plugin or something, but I couldn't find anything in my search. (Admittedly I didn't look *very* hard though)
vanceism7 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create tags while importing from source folder structure eamonned Library Management 5 01-28-2019 10:37 AM
Create TOC from non linear structure Cilex Conversion 3 10-01-2016 09:16 PM
Development eDGe Library filesystem and backup structure kenjennings enTourage Archive 3 05-26-2011 02:29 PM
Development eDGe Library filesystem and backup structure kenjennings enTourage Archive 0 04-27-2011 02:57 AM
How to create "Genre" expandable tree structure in Tag Browser? meads Library Management 3 02-20-2011 03:43 PM


All times are GMT -4. The time now is 07:41 AM.


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