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 04-29-2011, 11:34 AM   #1
noimporta
Member
noimporta began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Apr 2011
Device: nook
Regexp for series in books library

Hi,

I want to bulk rename a list of books with the following naming pattern:


Quote:
Series_name series_number - book_title

so I select the list and in bulk metadata I set a regexp to grab in title:


Quote:
(.*) - .*
and then I set destination either series or series index to


Quote:
\1

therefore in the sample part I see it works as:


Quote:
series_name series_number

but doesn't actually write the metadata.

I could do the same by enabling series in the basic metadata section but not all the series titles are in my collection, maybe I have from 1-20 and then 24-40 so if i make it the basic way it autoadds the 24-40 as 21-36 , that's why I wanted to use the regexp in search and replace.

Could anyone help me?

Last edited by noimporta; 04-29-2011 at 11:38 AM. Reason: sorting the code in quotes
noimporta is offline   Reply With Quote
Old 04-29-2011, 11:51 AM   #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: 29,659
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Are you trying to store Series info in the Title

Calibre has a Series field for that and a series_index for the sequence number(displayed in the square braces after the series name in Library view).

Bulk Metadata Edit (main tab) has a tool that can be used (with care ) to sequence WITHIN a series.
Lots of if's and 1 series at a time
Then there is the search and replace tab. Your Replace is rather tricky, so I would copy (a right click function on selected books) a batch of books to a 'test library'
and work until you get it right. You are dealing with multi-field replace(fill)
theducks is offline   Reply With Quote
Old 04-29-2011, 11:53 AM   #3
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Assigning
Code:
series_name series_index
where series_index is a number to a series type column is, to my knowledge, not valid. Use
Code:
series_name [series_index]
instead to set the series name and index in one go.
Manichean is offline   Reply With Quote
Old 04-29-2011, 12:36 PM   #4
noimporta
Member
noimporta began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Apr 2011
Device: nook
@theducks no, I'm not trying to do that but the opposite. My entry in the database has the series name series index - book title in the title field and I want to trim that. Therefore I'm trying to scrape series name and index into the series field.

I was trying to do that with the search & replace in bulk metadata mode.

@Manichean where can I perform both operations at once? In search & replace I managed to do it in 2 passes but I was trying to get it working in one. I've setup one to grab the series name and set it and then another to grab the series index and set it. So far I don't know how to input both at the same time since I can only grab one item from the replace list.

Just in case anyone finds the case fitting for their needs:

I want to trim the following name convention:
series_name series_number book title

First I apply the series name to the files:
search title for
Quote:
(*.)([0-9][0-9]) - .*
replace series name with
Quote:
\1
in the second pass I grab and set the series index
search title again for
Quote:
(*.)([0-9][0-9]) - .*
replace series index with
Quote:
\2

Last edited by noimporta; 04-29-2011 at 12:40 PM.
noimporta is offline   Reply With Quote
Old 04-29-2011, 12:59 PM   #5
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Try searching for
Code:
(.*?) (\d+) - .*?
and replacing with
Code:
\1 [\2]
in the series field. That should work.
Also note that in the regexes in your last post, the first group '(*.)' is probably wrong, you most likely meant to use '(.*)'.
Manichean is offline   Reply With Quote
Old 04-30-2011, 03:48 PM   #6
noimporta
Member
noimporta began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Apr 2011
Device: nook
@Manichean thx a lot , it worked just fine.

But now a new problem came up. In the field tag I have all kind of info stored for some books and I want to extract the 13 character isbn to the identifier isbn.

A tag could be:
Quote:
1234567891 1234567891234 :::: springer
I want to search the 13 digit isbn and store in the isbn identifier. I can match the 13 isbn but I don't know how to store it

Quote:
[0-9]{13}
will match the 13 chars of the isbn... but then how do i replace? ;D

I forgot to add that not all tags are the same sometimes its
Quote:
springer :: 1234123412341
so the regexp should find the 13 and replace it.

Last edited by noimporta; 04-30-2011 at 03:53 PM.
noimporta is offline   Reply With Quote
Old 04-30-2011, 06:03 PM   #7
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
.*([0-9]{13}).*

replace with \1
into identifiers
isbn
drMerry is offline   Reply With Quote
Old 04-30-2011, 06:17 PM   #8
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
I'd suggest you go read the tutorial. While you seem to have a basic grasp of regexes, there are some concepts you're not entirely clear on
You should pay special attention to the parts about quantifiers and backreferences
Manichean is offline   Reply With Quote
Old 04-30-2011, 07:22 PM   #9
noimporta
Member
noimporta began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Apr 2011
Device: nook
@Manichean : you're correct sir, i'm no programmer ;D but I read the tutorial to check if i could get it right.

@drmerry : that doesn't seem to work.

Quote:
something ::: 0071743123 9780071743123
that regexp will keep
Quote:
something ::: 9780071743123
not only the 9780071743123 part.

but i'll keep investigating, thanks guys
noimporta is offline   Reply With Quote
Old 04-30-2011, 07:31 PM   #10
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: 29,659
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by drMerry View Post
.*([0-9]{13}).*

replace with \1
into identifiers
isbn
just to make it a little more robust It must always start with 97n

(97[7-9][0-9]{10})
theducks is offline   Reply With Quote
Old 05-01-2011, 03:42 AM   #11
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by noimporta View Post
@Manichean : you're correct sir, i'm no programmer ;D but I read the tutorial to check if i could get it right.
Using regexes has absolutely nothing to do with being a programmer or not.
Manichean is offline   Reply With Quote
Old 05-01-2011, 06:45 AM   #12
noimporta
Member
noimporta began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Apr 2011
Device: nook
You're right, I guess what I tried to say I'm not very good at regexps.

Quote:
.*([0-9]{13}).*

replace with \1
into identifiers
isbn
@drmerry's suggestion wouldn't work either. I think what I'm trying to do is a reverse lookahead, from what I've read about it.

But I'm nowhere near implementing it. I've tried regexp coach as suggested in some other thread but it won't help me much, I think I don't understand the concept.
noimporta is offline   Reply With Quote
Old 05-01-2011, 07:53 AM   #13
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Hm. That ought to work. What are you getting in the destination field?
Manichean is offline   Reply With Quote
Old 05-01-2011, 08:03 AM   #14
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,691
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
My understanding is that you want to process tag that are ISBNs, grab the value, and then put it into the identifiers field. This can be done with edit metadata search/replace. However ...

Assigning a 'multiple' column (tags) to a non-multiple column (isbn) can lead to unexpected behavior. Because the source field is multiple, search/replace processes each tag individually. The search & replace expressions alter the individual values before copy, then each tag value is added to the non-multiple identifier. This isn't what you want. Instead, you want the tags to be processes as a non-multiple so that the search, replace, and copy happens once per book. To do this, convert tags to a non-multiple column using the template feature, then extract the ISBN, then assign that extraction to the identifier.

See the attached screen capture.
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.png
Views:	305
Size:	53.0 KB
ID:	70772  
chaley is offline   Reply With Quote
Old 05-05-2011, 08:20 AM   #15
noimporta
Member
noimporta began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Apr 2011
Device: nook
@chaley thanks, that worked
noimporta is offline   Reply With Quote
Reply

Tags
regexp, series, title

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Different export filenames for series / non-series books? HarryT Calibre 3 08-18-2010 12:30 PM
Author, Series, Series #, Books diokdin Calibre 19 05-14-2010 05:36 AM
Pet peeve: series authors who introduce things in non-series books! ficbot Reading Recommendations 12 02-06-2010 02:14 AM
Parse book titles to fill in series in Calibre library Marcika Calibre 1 11-25-2009 05:35 PM
BAEN Free Library - Harrington series JWLaRue Upload Help 59 03-10-2008 02:53 PM


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


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