![]() |
#1 | |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Jul 2014
Device: Kindle Paperwhite2
|
Bulk metadata edit dialog: Use of regular expressions - how to?
Hi there!
I would need a hint how to insert a text at the beginning of the title field in the search and replace tab of the bulk metadata edit dialog. I am somehow as bit lost with the documentation for regular expressions and don´t get this to work. Here is an example of what I try: Text to insert: "Hero´s name - " Titles: Adventure on the hill Adventure at seaside Adventure in the living room Desired result: Hero´s name - Adventure on the hill Hero´s name - Adventure at seaside Hero´s name - Adventure in the living room Optionally (or better: perfect), it would be cool to copy the content of the series field including index number and insert ist at position of Hero´s Name. Hero´s name [1] - Adventure on the hill Hero´s name [2] - Adventure at seaside Hero´s name [3] - Adventure in the living room This would be the easiest way and acoording to the Calibre manual it should work. Quote:
Has somebody done this already and could possibly help me out? Regards, Olli |
|
![]() |
![]() |
![]() |
#2 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,944
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Olli
You should not normally code Series info in the Title Name within the library Use the Series field: Heros name [index] When sending to a device use a Template: {series} [{series_index}] - {title} |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,662
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
![]() BR |
|
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Jul 2014
Device: Kindle Paperwhite2
|
Thank you both for your good advices!
I´ll give the pugin a try and agree, that the usual way is to use the Series column. I do so usually as well inside the library. However sometimes there is wrong or unsufficient metadata which is needed to be changes for several titles (or other fields) in a row, so I still would like to learn more about the usage of regular expression in the bulk search and replace dialog. Somehow I am only able to use this dialog in the "standard" way by replacing strings, but this requires somthing common in the title fields. For total different titles, there must be a way to use the complete title string in a variable in the search field and use this full string in the replace field with a addition or change. If there is a workshop or so for this topic I would be thankful. Please see this as a technical question, not as a question of intended usage of particular fields. Thanks and regards, Olli |
![]() |
![]() |
![]() |
#5 |
Handy Elephant
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,737
Karma: 26785684
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Samsung Galaxy Tab S8 Ultra
|
There are two possible problems. The calibre interface and the syntax of regular expressions. If you don't already know regular expressions, then I would suggest that is where you should start. There are books and whole websites about it. And also several posts here that tries to explain specific regexp search and replaces.
The interface is simple and doesn't differ from common practice. You create a regexp to match a field, with parentheses to be able to reference parts, and replace with a string that may include references to the parts designated with parentheses. I assume that you have read what the manual has to say about it: http://manual.calibre-ebook.com/regexp.html Last edited by Adoby; 07-13-2014 at 08:32 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
I found this website to be very helpful in learning regex: http://regular-expressions.info
|
![]() |
![]() |
![]() |
#7 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,662
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Jul 2014
Device: Kindle Paperwhite2
|
Thanks to all, the links have been very useful!
Just in case somebody has the same problem or needs, here is my solution. Most important: In the search and replace dialog, change search mode from "Character match" to "Regular Expression". I stumbled exactly over this point at the beginning as I thought, Calibre would recognize the RegEx automatically by its syntax, like my file manager does. No wonder, that nothing I tried in the beginning worked! ![]() ![]() Inserting series info into the title field: Works for mixed titles with and without filled series fields: Search field: {template} Template: {series} {series_index:0>2s|| - } {title} Search for: (.*) Replace with: \1 Destination field: title If the series contains more than 99 books, you might want to replace the "2s" in the template by "3s". Result will be 001 insted of 01 for the first book. Output format will be normally Series-name 01 - Title If someone prefers the format Series-name 01: Title use instead: Template: {series} {series_index:0>2s||: } {title} Opposite way: Moving series name and index from title field to series fields. The RegEx below works for these title formats: Hero´s name 001 - Adventure on the hill Hero´s name 2 - Adventure at seaside Hero´s name 4: Adventure in the swamp Result should be: TITLE fields Adventure on the hill Adventure at seaside Adventure in the swamp SERIES fields Hero´s name [1] Hero´s name [2] Hero´s name [4] Step 1 - Copies series name name to series field Search field: title Search for: (.*?) (\d+)(: | - ).* Replace with: \1 Destination field: series Step 2 (Optional) - Copies series index to series_index field. Use, if the series is not complete (missing intermittend titles). Not needed for complete series, as Calibre can set the index automatically ascending. Search field: title Search for: (.*?) (\d+)(: | - ).* Replace with: \2 Destination field: series_index Step 3 - Deletes complete series infto from title Search field: title Search for: .*?(: | - ) Replace with: Destination field: title or blank Note: Leave "Replace with" empty (no space). One more: Adding a note behind a set of titles: Search field: title Search for: (.*) Replace with: \1 (my note) Destination field: title or blank As is is stated in the Calibre manual, please use these with caution and make sure that you always select the correct search and destination fields! However, I tested the searches above in both directions and with different files, worked fine for me and I saved the searches for quick access. Regards, Olli |
![]() |
![]() |
![]() |
#9 | |||
US Navy, Retired
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,895
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Kindle PaperWhite SE 11th Gen
|
Thanks for sharing. I'm glad you got it sorted out to your satisfaction.
![]() Quote:
If the goal is to ensure the series info in the Title field so it is reflected on the device, calibre has Metadata plugboards to insert whatever you want into the title field on the fly as the book is sent to the device. If the goal is to sort your calibre library you can set a default sort and how many columns deep you wish to be able to sort the GUI by going to Preferences - Tweaks and setting the following tweaks: # Specify columns to sort the booklist by on startup example Quote:
example Quote:
Last edited by DoctorOhh; 07-14-2014 at 08:30 AM. |
|||
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Open file option from 'Edit Metadata' dialog box | crackhammer | Library Management | 1 | 12-04-2013 04:39 PM |
remove series in edit metadata dialog | speakingtohe | Conversion | 2 | 04-01-2012 12:19 PM |
Metadata from filename (regular expressions) | geronimo72 | Library Management | 2 | 03-05-2012 04:14 PM |
Could use a bit of help with regular expressions to edit books on conversion | Flammy | Conversion | 3 | 12-29-2011 10:29 AM |
Minor bug: tab order on bulk edit dialog in 0.7.23 | kiwidude | Calibre | 1 | 10-11-2010 11:45 AM |