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 12-05-2015, 01:20 PM   #1
jrkotrla
Junior Member
jrkotrla began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Mar 2009
Device: Sony PRS-500, Treo 755p, REB 1100, eBookman 911
Question Bulk Meta Edit (regex troubles)

Hey guys,

I'm trying to edit some bulk data using regex and I'm having trouble matching groups. I wasn't paying attention when importing, so now I have author fields that can include author, author and series, or author, series, and series number.

I'm trying to match series and seriesnum out of the author field and send them to the appropriate places using the bulk meta edit tool. the expression I'm using right now is:
([a-zA-Z.\ ]+) (\-) ([\ \w]*) (\d+)
which matches "A. J. Author - Series of Books 01"

I can then use \3 to send "Series of Books" to series and \4 to send "01" to seriesnum.

The problem is when it finds an author field with just an author and no series number or series (i.e. "A. J. Author"). In that case \3 and \4 also match "A.J. Author" though it seems they should be blank instead since they shouldn't exist.

Can anyone help me figure this out?
jrkotrla is offline   Reply With Quote
Old 12-05-2015, 04:10 PM   #2
fidvo
Addict
fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.
 
Posts: 309
Karma: 1645952
Join Date: Jun 2012
Device: none
Maybe filter the books in the main window first to include only books with a "-" in the author, then run the regex on only that set?
fidvo is offline   Reply With Quote
Advert
Old 12-05-2015, 07:50 PM   #3
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
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)
Why are you escaping the dashes and spaces?


As for your mysterious problem, calibre replaces one field with another, after trying the regex replacement.
Since the replacement failed, the fields are copied over as-is.

This has tripped me up too.
eschwartz is offline   Reply With Quote
Old 12-06-2015, 06:00 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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
@eschwartz: FWIW (which isn't much) the way I mentally handle this problem is to remind myself that a replacement only occurs if the entire search pattern successfully matches against the source, and that in that case only the matched segment of the source is replaced. I often find myself sticking anchors and .*s in odd places to be sure that the pattern matches the entire source.
chaley is offline   Reply With Quote
Reply

Tags
bulk edit metadata, meta data, regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bulk meta and series info gabby98 Calibre 11 12-21-2013 12:48 PM
Regex help: Edit Meta Search & Replace: Pad with zero _noel_ Calibre 4 11-26-2012 04:31 PM
Bulk Edit of comments using regex PeterT Library Management 2 07-25-2012 08:10 AM
Bulk metada edit error trying to edit tags Purple Lady Calibre 8 02-17-2011 06:09 PM
Bulk Meta Data Edit Resetting Custom Field toomuchreading Calibre 8 10-22-2010 10:19 PM


All times are GMT -4. The time now is 05:10 PM.


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