Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 03-01-2024, 10:24 AM   #1
LunaLark
Junior Member
LunaLark began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Mar 2024
Device: none
How can I replace the Titles with the Filenames?

I downloaded an epub, but all of the titles are the same and it makes navigating the Table of Content impossible as there are over 500 chapters.

I figured out how to rename all of the file names at the same time, but I can use the same method to rename the ToC.

Is there a way to use the find & replace tool to rename the titles all at once with the filenames?
LunaLark is offline   Reply With Quote
Old 03-01-2024, 10:33 AM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
What titles? Are you talking about the title tag inside the head tag? Or are you saying all of the 500 chapters in the Table Of Contents report the exact same titles?

If the latter, look at the first couple files and look for the h1 or h2 tags? Are they properly set to be that chapter's unique title?

If you, you should be able to just use the Sigil tool that rebuilds the Table Of Contents automatically. But do a file save as first, to create a backup epub.

If there are no header tags (h1, h2, h3, ...) used, then you will need to show the structure of p or div tags used to create the chapter title. We can lead you though using regex to replace those with the proper header tags so that the TOC tool can be then used.

A couple of screenshots to show the top of the a chapter would help.

Last edited by KevinH; 03-01-2024 at 10:37 AM.
KevinH is offline   Reply With Quote
Old 03-01-2024, 10:53 AM   #3
LunaLark
Junior Member
LunaLark began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Mar 2024
Device: none
The title is inside <title> </title>

is then repeated again in <h2 class="chapter-title"> </h2>

while the actual title is inside <span> </span>

all of the chapters in the ToC are exactly the same
Attached Thumbnails
Click image for larger version

Name:	chapter 1 sigil forum.png
Views:	63
Size:	18.0 KB
ID:	206633  
LunaLark is offline   Reply With Quote
Old 03-01-2024, 11:20 AM   #4
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
That is quite the mess.

Your screen shot did not show if the first child div of the body tag ends right after the p with the span tag that holds the actual title.

If so you could use regular expression search for that first child div, capture it, extract the title info, then replace that entire first div (and its children) with a much simpler properly formatted single header all in a single pass.

If instead that first child div encompasses the entire body that approach will not work. Then a multiple pass approach is needed and possibly the need to use the Python Function Replace plugin.

If all the Chapter titles are simply an incrementing series, then just the Python Function Replace plugin may be enough.

That structure is so bad though, you may want to strip all that unneeded dross out and reformat the entire thing.

Last edited by KevinH; 03-01-2024 at 11:29 AM.
KevinH is offline   Reply With Quote
Old 03-01-2024, 11:34 AM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Alternately, capture the entire first p tag with span child and replace it with a proper h2 tag and proper contents in pass 1.

In pass 2, delete the previously existing earlier h2 tag, using either regular expressions or the nice TagMechanic plugin for Sigil.

May need a third pass to remove leftover/broken div pieces.

Once you have h2 tags with the correct info, you can rebuild the entire TableOfContents using Sigil's menus.

My AccessAide plugin can then be used to take proper TOC headers to backfill in any *empty* title tags in head. You can empty the crap out of them using a normal find and replace before running that plugin.

Last edited by KevinH; 03-01-2024 at 11:40 AM.
KevinH is offline   Reply With Quote
Old 03-01-2024, 12:49 PM   #6
LunaLark
Junior Member
LunaLark began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Mar 2024
Device: none
Fixed! Thank you!!
LunaLark is offline   Reply With Quote
Old 03-01-2024, 12:57 PM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Glad to hear it.
KevinH is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
10% Credit Towards Great on Kindle Titles When Purchasing One of Those Titles Manabi Deals and Resources (No Self-Promotion or Affiliate Links) 0 11-01-2019 01:07 AM
fixing mising titles/addition titles Rellwood Library Management 2 08-21-2019 04:34 PM
How to stop putting ", The" at the end of titles and series in filenames Emparawr Calibre 4 06-16-2013 09:48 PM
search and replace - drops blanks in replace ? cybmole Conversion 10 03-13-2011 03:07 AM
Filenames to metadata, preserving filenames. nitrogun Calibre 5 09-13-2010 10:50 PM


All times are GMT -4. The time now is 04:01 PM.


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