Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-13-2011, 08:43 AM   #1
flopis
Member
flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.
 
Posts: 17
Karma: 7700
Join Date: Jan 2011
Device: kindle
Variable Search, Replace & Transfer to a new field

Calibre computes 12,000 reports & books, and 3 thou authors (which should be about 500). My author and title fields in my library are all messed up.

I would like to fix them with the search and replace in the bulk edit feature. Here are my specific questions:

1) In the author field I have several occurrences of "Lastname", "Firstname" for several authors. How can I correct this to Firstname Lastname in a variable way so that it respect the names of the different authors.
2) In the title field I have author, titles and series; sometimes separated by " - ", and other times by ":" How can I eliminate non-title info and transfer the series info to the series field?

For instance, I have -say- 20 occurrences for:
Alexander, Lloyd - Chronicles of Prydain 01 - The High King, Alexander, Lloyd - Chronicles of Prydain 02 - The Black Cauldron, ... Alexander, Lloyd - Chronicles of Prydain 20 - The Black Song.

What I have being doing --in Search & Replace (bulk meta edit), in the "search field title" (Regular Expression Mode)-- is the following:
(a) eliminate the author " Alexander, Lloyd - " by giving it a Search (I leave Replace blank), and
(b) eliminate the series info " Chronicles of Prydain xx" with the following command in the Search Field "Chronicles of Prydain [0-9]+ - ".

I end up with only the titles. However, that takes too long for so many authors and books.
I have already seen http://calibre-ebook.com/user_manual/template_lang.html and http://calibre-ebook.com/user_manual/regexp.html.
I have also experimented with the following expressions: (...), \\n, etc., but I have messed up.

Can anybody help me?
flopis is offline   Reply With Quote
Old 01-13-2011, 09:17 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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
To swap the names of an author containing a comma, try
search: (.*),(.*)
replace: \2 \1

To blow away everything up to the last - character in the title:
search .*-
replace: empty
chaley is offline   Reply With Quote
Advert
Old 01-13-2011, 10:45 AM   #3
flopis
Member
flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.
 
Posts: 17
Karma: 7700
Join Date: Jan 2011
Device: kindle
Yes, that works. Thanks!
But what about when you have (apart from the names), series info in the authors field. How can you take it out of there and copy it to its respective field.
Is there a way to do it in one simple command?
flopis is offline   Reply With Quote
Old 01-13-2011, 10:49 AM   #4
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by flopis View Post
Yes, that works. Thanks!
But what about when you have (apart from the names), series info in the authors field. How can you take it out of there and copy it to its respective field.
Is there a way to do it in one simple command?
Probably, but without examples I can't propose anything.

What you will do is use different source and destination fields. The source will be author, or perhaps {template} if there are multiple authors involved. The destination will be series. You carve out the appropriate text using the source regexp and put it in the destination.

Have you read the regexp tutorial? It tells you everything you need to know to do this sort of text carving.
chaley is offline   Reply With Quote
Old 01-13-2011, 11:11 AM   #5
flopis
Member
flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.
 
Posts: 17
Karma: 7700
Join Date: Jan 2011
Device: kindle
First of all, thanks for the help and your valuable time.

Here is an example of the info I have in the author field:
26 occurrences for:
Lumpus, Sardineli - Tales of After 01 - The Idiot King
Lumpus, Sardineli - Tales of After 02 - The Pink Sock, ...
.
.
.
Lumpus, Sardineli - Tales of After 20 - The Pink Song.

How can I transfer the series and title info into their respective fields?

Yes, I have used different source and destination fields. But, LOL, my results are dismal.
I guess the way to go would be with templates, since there are multiple authors, but my knowledge is scant.
Yes, I read the regexp tutorial, which helped me to use several commands, but I still have not been able to do the carving appropriately.
flopis is offline   Reply With Quote
Advert
Old 01-13-2011, 01:02 PM   #6
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Fortunately, all of these are single author, so you can avoid templates.

You must do this in three steps, one to move series, one to move title, and one to clean author.

1. Series.
source: author
search: .*- (.*)(\d) -.*
replace: \1 [\2]
dest: series

2. Title
source:authors
search: .*- (.*?)
replace: \1
dest: title

3: authors
source:authors
search:(.*?) - .*
replace: \1
dest: authors

I strongly advise that you check the test windows carefully before letting any of these hammer your db. You might want to make a backup of your library.
chaley is offline   Reply With Quote
Old 01-14-2011, 01:05 PM   #7
flopis
Member
flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.
 
Posts: 17
Karma: 7700
Join Date: Jan 2011
Device: kindle
Thanks chaley...
I finished with all the library... thanks to you!!!

Last edited by flopis; 01-14-2011 at 02:08 PM.
flopis is offline   Reply With Quote
Old 01-19-2011, 12:41 PM   #8
flopis
Member
flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.
 
Posts: 17
Karma: 7700
Join Date: Jan 2011
Device: kindle
By the way, the & character is not subject to search and replace, not even with \...
Is that a bug, or am I doing something wrong?
flopis is offline   Reply With Quote
Old 01-19-2011, 01:19 PM   #9
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: 11,733
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by flopis View Post
By the way, the & character is not subject to search and replace, not even with \...
Is that a bug, or am I doing something wrong?
Are you trying to replace the & in an authors field?

S/R knows whether a field is a multi-value field or not. If a field is multi-valued, then S/R operates on one value at a time. The result of editing each individual value is written to the DB.

The separation character you see for authors is &. That character doesn't really exist, but is instead used to indicate the end of one author and the start of another. That is why you can't edit it -- it isn't there. The same thing is true for commas and tags.

There is no issue when editing single-value fields, such as title.

One of the reasons I supplied template input mode was to permit a multiple field to be operated on as a single string instead of as a set of values. If you use the template {authors} as the input field and authors as the output field, then you can add and remove & characters. This feature can be used to join names back together for some reason split apart, or to split authors into two (or more).

You don't need template mode to split an author. Just stick ' & ' (space ampersand space) somewhere in the middle of an author.
chaley is offline   Reply With Quote
Old 01-21-2011, 08:54 PM   #10
flopis
Member
flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.flopis knows the square root of minus one.
 
Posts: 17
Karma: 7700
Join Date: Jan 2011
Device: kindle
Thanks, I will try it...
flopis is offline   Reply With Quote
Old 03-09-2011, 11:41 AM   #11
theaccountant
Enthusiast
theaccountant began at the beginning.
 
Posts: 26
Karma: 10
Join Date: Mar 2011
Device: Awful Hanvon N518
Sorry to jump on this thread. Do I understand that i cannot edit the authors field without using a template?
I am trying to change extract the following from author to correct columns.
Last Name, First name - Series Series no.
As you see there is no clear divider between series and series no except space. Should i switch author and title and do the three step process above or is there a simpler way?

Thanks in advance.
theaccountant is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search & Replace - Regular expression oldbwl Calibre 2 01-09-2011 09:33 AM
Search & Replace Suggestion Philosopher Calibre 6 12-31-2010 11:55 AM
Search & Replace: Destination series_index? Starson17 Calibre 0 12-09-2010 01:12 PM
Search & Replace Pat Nickholds Sigil 2 10-21-2010 11:18 PM
Search & replace TEXT ToeRag Calibre 3 04-10-2010 01:44 PM


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


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