Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 04-17-2022, 11:14 PM   #1
zakman
Enthusiast
zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.
 
Posts: 35
Karma: 2119794
Join Date: Jan 2016
Device: Kindle Paperwhite 2019
Cleaning up with Search & Replace

So I just imported a list of my books from Goodreads into Calibre and need to do some cleanup. All of the imported books that are part of a series are now titled like so (apologies for extra ASCII):

Title---------------------------------------------------------Series
=======================================
Book Name (The Blah Saga, #7)-------------------------(empty)

If possible, I'd like to change the metadata so it's more in line with the rest of my library:

Title------------------Series
===============================
Book Name----------The Blah Saga [7]

Is this possible? If so, how? I'm pretty new to maniupulating the data like this in Calibre, so the more details, the better. Thanks!
zakman is offline   Reply With Quote
Old 04-18-2022, 12:23 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Moderator Notice
Moved from Template Questions to its own thread
chaley is offline   Reply With Quote
Advert
Old 04-18-2022, 07:39 AM   #3
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by zakman View Post
So I just imported a list of my books from Goodreads into Calibre and need to do some cleanup. All of the imported books that are part of a series are now titled like so (apologies for extra ASCII):

Title---------------------------------------------------------Series
=======================================
Book Name (The Blah Saga, #7)-------------------------(empty)

If possible, I'd like to change the metadata so it's more in line with the rest of my library:

Title------------------Series
===============================
Book Name----------The Blah Saga [7]

Is this possible? If so, how? I'm pretty new to maniupulating the data like this in Calibre, so the more details, the better. Thanks!
You can do this with calibre's bulk metadata search and replace. It requires 3 search/replace operations.

The steps:
  1. *Back up your library*. Things can go very wrong and you might need to get back to ground 0.
  2. Assuming you have more than one book, press E to open bulk metadata edit.
  3. Click on the Search and replace tab.
  4. If needed, change the Search mode to "Regular Expression.
  5. Do the first search and replace to copy the series number to calibre's series_index column.
    Click image for larger version

Name:	Clipboard01.jpg
Views:	83
Size:	151.9 KB
ID:	193301
    Press the Apply button.
  6. Do the second S/R to copy the series name to calibre's series column.
    Click image for larger version

Name:	Clipboard02.jpg
Views:	70
Size:	156.3 KB
ID:	193302
    Press the Apply button.
  7. Finally, remove the extraneous information from the title.
    Click image for larger version

Name:	Clipboard03.jpg
Views:	77
Size:	152.6 KB
ID:	193303
    Press the OK button to apply the S/R and close the dialog.
The regular expression
Code:
^(.*) \((.*), #(\d*)\)
says Starting at the beginning of the line (the title) find all characters up to " (", capturing them in the first capture group. Next the characters up to ", #" (the series name) are captured in group 2. Finally, the digits up to the closing ')' are captured in group 3.

Note that the images show the regular expression
Code:
^(.*).*\((.*), #(\d*)\)
The one above replaces the ".*\(" with " \(", which is cleaner. I didn't bother to remake the images.
chaley is offline   Reply With Quote
Old 04-18-2022, 02:28 PM   #4
zakman
Enthusiast
zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.zakman ought to be getting tired of karma fortunes by now.
 
Posts: 35
Karma: 2119794
Join Date: Jan 2016
Device: Kindle Paperwhite 2019
Thanks. After working through this a couple of times (and cleaning up between each one), I am now getting a "could not convert string to float" error when trying to run the first S/R. This happens even on a smaller selection of books that I know for sure should match up with the regular expression. Time to restore my backup, I guess?

EDIT: Working with it some more, it appears to only match on books where the series name is a single word. For example:

Click image for larger version

Name:	clip01.png
Views:	78
Size:	20.2 KB
ID:	193311

If the screenshot didn't come through:

The title "The Android's Dream (The Android's Dream #1)" does not appear to be recognized by the expression and is unchanged from the "Text Test" to the "Test Result" columns.

The title "Animal Farm (FarmyAnimal, #1)" IS recognized and "Test Result" shows a "1".

Continuing through the rest of the S/R's looks like they are working as planned. Seems to be just the multi-word series giving me problems.

Last edited by zakman; 04-18-2022 at 02:48 PM.
zakman is offline   Reply With Quote
Old 04-18-2022, 02:38 PM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by zakman View Post
Thanks. After working through this a couple of times (and cleaning up between each one), I am now getting a "could not convert string to float" error when trying to run the first S/R. This happens even on a smaller selection of books that I know for sure should match up with the regular expression. Time to restore my backup, I guess?
That means that at least one of the books has something odd where the series number should be, where by 'odd' I mean there isn't a number there. Check each book to be sure that what follows the '#' character is a number.
chaley is offline   Reply With Quote
Advert
Old 07-31-2022, 01:40 PM   #6
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 893
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
I have the name of the series and the number before the title, how would the regular expression be to clean it?
example:
Series Name #015 - Book Title
I want only the title to remain in its field
dunhill is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a search&replace ownedbycats Library Management 3 03-08-2021 04:53 PM
Regex in search problems (NOT Search&Replace; the search bar) lairdb Calibre 3 03-15-2017 07:10 PM
Search & Replace Help paulfiera Conversion 7 08-06-2015 03:52 AM
Help with a search & replace mmholt Library Management 11 10-21-2011 06:49 PM
Cleaning Title Names using Search and Replace JTAL604622 Calibre 2 05-24-2011 05:23 AM


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


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