Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-06-2026, 01:45 PM   #1
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 324
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Using Editor to mass delete anything contained in a Class?

I used the FanFicFare plugin to download a work from RoyalRoad. Near the beginning and/or the end of most of the chapters is an author's note, which I'd like to remove. There are over 600 chapters, I don't want to do it manually.

Each of these notes is within a section marked as follows:

< div class="portlet" >

Which seems like it would be easy to clear, but there are more < div > within the note, so I can't just regex with < /div > as the endpoint of the find.

Any thoughts on how to handle this?

Full code chunk with plaintext changed:

Code:
<div class="calibre1"><div class="portlet">
                    <div class="calibre1">
                        <div class="calibre1">
                            
                            <span class="calibre2">A note from Author</span>
                        </div>
                    </div>
                    <div class="calibre1"><p class="calibre4"><span>I want to thank all of my patrons, including:</span></p>
<p class="calibre4"><span>Person</span></p>
<p class="calibre4"><span>Person</span></p>
<p class="calibre4"><span>Person</span></p>
<p class="calibre4"><span>And my 2 other patrons!</span></p>
<p class="calibre4"></p>
<p class="calibre4"><span>Thank you!</span></p>
<p class="calibre4"></p>
</div>
                </div>
fogice is offline   Reply With Quote
Old 08-06-2026, 02:17 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: 31,917
Karma: 64187770
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Use the following Calibre (editor) Plugin
https://www.mobileread.com/forums/sh....php?p=2980740
It accepts arguments on which to apply
theducks is offline   Reply With Quote
Advert
Old 08-06-2026, 02:32 PM   #3
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 324
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Quote:
Originally Posted by theducks View Post
Use the following Calibre (editor) Plugin
https://www.mobileread.com/forums/sh....php?p=2980740
It accepts arguments on which to apply
Nice tool! But I don't think it does what I want it to. It successfully removed the div in question. However, it left all the text within the div. I want to remove the whole block (in my example, the list of patrons).
fogice is offline   Reply With Quote
Old 08-06-2026, 04:28 PM   #4
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,891
Karma: 9600930
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
This will take a few separate regex's to accomplish.

First you need to "Fix HTML - All files" and then "Beautify all files" which are tools in the editor. The spacing, tabs and layout look a mess. You need to get consistency across all the tags.

You also need to check that the classes being used in the tags are unique to these Authors Notes otherwise you will also be removing parts of the book you want to keep.

Then you need to step through the regexes. Remember to also capture the tabs and line before so you don;t end up with lot's of spacing.
Start with removing the empty <p class="calibre4"></p> tags.
Then remove the <p class="calibre4"><span>(.*?)</span></p> tags.
Then remove the <div> tags using Edit Spans & Divs, which I think is part of Diap's Toolbag plugin.
Then run the "Fix HTML - All files" and then "Beautify all files" again to remove all the extra line feeds.
Karellen is offline   Reply With Quote
Old 08-06-2026, 04:53 PM   #5
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 324
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Quote:
Originally Posted by Karellen View Post
This will take a few separate regex's to accomplish.
Thanks for this very clear writeup!

Unfortunately, as I dug further into the edits, things keep changing in the layout, and sometimes the classes are reused for things that need to be kept. But I've learned a lot today, and it will be useful for future edits.
fogice is offline   Reply With Quote
Advert
Old 08-06-2026, 05:01 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 84,438
Karma: 153744815
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by fogice View Post
Thanks for this very clear writeup!

Unfortunately, as I dug further into the edits, things keep changing in the layout, and sometimes the classes are reused for things that need to be kept. But I've learned a lot today, and it will be useful for future edits.
It sounds like a manual edit of all 600 chapters is in order.
JSWolf is offline   Reply With Quote
Old 08-06-2026, 06:26 PM   #7
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 196
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
Is the .portlet class reused? If not, you can skip working with the html and use the stylesheet:

div.portlet {display: none;}
Brett Merkey is offline   Reply With Quote
Old 08-06-2026, 08:58 PM   #8
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,891
Karma: 9600930
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by fogice View Post
things keep changing in the layout, and sometimes the classes are reused for things that need to be kept.
I am wondering if you could be more strict with the search for those classes reused elsewhere in the book.

Maybe you could be strict on the spacing. Something like...
\s{6,12}<p class="calibre4"><span>
The numbers in the brackets are min,max spaces to search for.

Without seeing the book, maybe the authors note, with multiple div wrappings, might bump the spacing more than what is used in the rest of the book.
Karellen is offline   Reply With Quote
Old 08-06-2026, 09:21 PM   #9
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: 46,434
Karma: 29634066
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Just FYI the correct tool to use for this is the Transform HTML tool which is under Tools->Transform markup

in it you can create a rule like if the tag has class whatever, remove it.
kovidgoyal is online now   Reply With Quote
Old 08-06-2026, 10:44 PM   #10
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,891
Karma: 9600930
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
If the same class is being used in the block to be removed, as well as in areas not to be removed, how do you ensure with the Transform tool that you do not remove the wrong elements?
Karellen is offline   Reply With Quote
Old 08-06-2026, 10:53 PM   #11
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: 46,434
Karma: 29634066
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by Karellen View Post
If the same class is being used in the block to be removed, as well as in areas not to be removed, how do you ensure with the Transform tool that you do not remove the wrong elements?
depends on what information is present to discriminate between the scenarios in the first place. My point was more that for the task of editing HTML rather than relying on regex which is fragile use the transform html tool.
kovidgoyal is online now   Reply With Quote
Old 08-07-2026, 09:24 AM   #12
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 324
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
Just FYI the correct tool to use for this is the Transform HTML tool which is under Tools->Transform markup

in it you can create a rule like if the tag has class whatever, remove it.
Oh, that was lovely.
Code:
If the tag has class portlet
Remove tag and children
That was exactly what I needed. One shot and 500 chapters are fixed. It's amazing how much depth and power Calibre contains, you are a genius, Kovid.
fogice is offline   Reply With Quote
Old 08-07-2026, 09:25 AM   #13
fogice
Addict
fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!fogice is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 324
Karma: 50000
Join Date: May 2014
Device: Kobo Libra 2
Quote:
Originally Posted by Karellen View Post
If the same class is being used in the block to be removed, as well as in areas not to be removed, how do you ensure with the Transform tool that you do not remove the wrong elements?
In my case, it was some classes like calibre4 and calibre2 that became other things in other chapters. The 'portlet' tag was consistent.
fogice is offline   Reply With Quote
Old 08-07-2026, 11:06 AM   #14
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,365
Karma: 1589505
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by fogice View Post
I used the FanFicFare plugin to download a work from RoyalRoad. Near the beginning and/or the end of most of the chapters is an author's note, which I'd like to remove. There are over 600 chapters, I don't want to do it manually.

Each of these notes is within a section marked as follows:

< div class="portlet" >

Which seems like it would be easy to clear, but there are more < div > within the note, so I can't just regex with < /div > as the endpoint of the find.

Any thoughts on how to handle this?
The regex below should work.
Choose 'Regex' mode and 'All text files'.
Remember to check the 'Wrap' and 'Dot all' options.
Code:
<div class="portlet">.*?<p class="calibre4"><span>Thank you!</span></p>.*?</div>
______
Edit: Nevermind. I didn't notice you already solved the problem.

Last edited by thiago.eec; 08-07-2026 at 11:09 AM.
thiago.eec is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mass delete of .mobi files lynncal Calibre 6 03-17-2024 08:53 PM
Recovery from aborted Mass Delete PickleBucket90 Library Management 3 11-10-2021 09:06 PM
How can I mass delete books from a Kindle? MisterSnrub Amazon Kindle 3 11-24-2019 08:58 AM
Mass delete of unpopular tags jacr Library Management 25 07-21-2018 10:43 PM
A way to mass delete Ids? raithe Library Management 9 10-22-2015 06:36 AM


All times are GMT -4. The time now is 11:58 AM.


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