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 11-06-2019, 08:24 PM   #1
anoukaimee
Member
anoukaimee began at the beginning.
 
anoukaimee's Avatar
 
Posts: 19
Karma: 10
Join Date: Aug 2017
Device: Kobo Clara, Pixel 2XL (Moon Reader/Calibre Companion)
Exclamation cannot figure out, please help: bulk metadata swap numeric mo/yr in title w/ regex

I apologize in advance because I think this is a super simple question, but I've been searching for hours and, for the life of me, I cannot seem to figure it out.

I have many periodicals for which I'd like to standardize the date in the title. I already went through and "manually" changed the months from alpha to numeric (e.g., "Jan" to "01"). I now realize that I'd like to also have the year first, followed by the month.

So, for instance, I have a bunch of Gardeners' World Magazines, that are currently inputted as:

Gardeners' World Magazine, [MONTH] [4 DIGIT YEAR]
e.g., "Gardeners' World Magazine, 01 2011" (that is, Jan 2011)

I would like to format them as:

Gardeners' World Magazine, [4 DIGIT YEAR]/[MONTH]
e.g., "Gardeners' World Magazine, 2011/01"

BUT I can't figure d**n regex out (even though I find it totally fascinating), specifically how to replace a pattern. I figured out that "\d{2} \d{4}" expresses the date as it is now formatted, which is great, BUT I can't figure out how to transform it to the desired pattern. Please see pic for clarification.

Thanks!
Attached Thumbnails
Click image for larger version

Name:	calibre search replace metadata.PNG
Views:	76
Size:	86.7 KB
ID:	174759  
anoukaimee is offline   Reply With Quote
Old 11-06-2019, 08:58 PM   #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: 26,278
Karma: 41365351
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Aura2, K4NT(Fixed: New Bat.), Galaxy Tab A
your search look good
it is your replace
you want to use the CAPTURED VALUE
(\d{2}) is the first capture
(\d{4}) is the second capture

Replace wants to USE those, just flipped

\2 /\1
theducks is offline   Reply With Quote
Advert
Old 11-06-2019, 09:31 PM   #3
anoukaimee
Member
anoukaimee began at the beginning.
 
anoukaimee's Avatar
 
Posts: 19
Karma: 10
Join Date: Aug 2017
Device: Kobo Clara, Pixel 2XL (Moon Reader/Calibre Companion)
Quote:
Originally Posted by theducks View Post
your search look good
it is your replace
you want to use the CAPTURED VALUE
(\d{2}) is the first capture
(\d{4}) is the second capture

Replace wants to USE those, just flipped

\2 /\1
Thank you for your help! I guess it is the notion of "capturing" that is confusing for me. How do you indicate that a string is what needs to be modified, rather than just "identifying" it? is it the parens as you have it:
(\d{2}) is the first capture
(\d{4}) is the second capture
And if so, what is the syntax to show that those should be inverted?

I ask because I tried plugging in just

(d{2}) (d{4}) for search AND
(d{4}) (d{2}) for test

and it's not changing anything (in the "your test" field, at least).

Really appreciate your help!
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	50
Size:	78.9 KB
ID:	174760  
anoukaimee is offline   Reply With Quote
Old 11-06-2019, 11:41 PM   #4
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: 26,278
Karma: 41365351
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Aura2, K4NT(Fixed: New Bat.), Galaxy Tab A
I showed you the PROPER replace for flipping
theducks is offline   Reply With Quote
Old 11-07-2019, 12:27 AM   #5
anoukaimee
Member
anoukaimee began at the beginning.
 
anoukaimee's Avatar
 
Posts: 19
Karma: 10
Join Date: Aug 2017
Device: Kobo Clara, Pixel 2XL (Moon Reader/Calibre Companion)
Quote:
Originally Posted by theducks View Post
I showed you the PROPER replace for flipping
Ok; I'm sorry, I still don't understand. I appreciate you want to help ppl who do their legwork, but I feel that I have. Sorry and thanks anyway.
anoukaimee is offline   Reply With Quote
Advert
Old 11-07-2019, 02:36 AM   #6
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 17,208
Karma: 19750289
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Yes, the parentheses in the search expression denote capture groups, they're notionally numbered from left to right, and they are referenced in replace expressions with a '\' (sometimes known as backslash or slosh) and number i.e. \1, \2, \3 etc

So, put \2/\1 into the Replace with: box and you'll have yyyy/mm.

BR
BetterRed is offline   Reply With Quote
Reply

Tags
metadata editor, regex

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing metadata(title and author) in bulk/by macro from filename possible? thosedays Reading and Management 0 10-20-2016 08:17 AM
Title sort option failing at bulk metadata edit Terisa de morgan Library Management 2 12-21-2015 04:10 AM
Regex search and replace in bulk metadata help slantybard Library Management 7 08-20-2015 06:30 PM
Bulk Metadata Title Help braxas Library Management 4 10-07-2013 03:57 AM
Regex help pls for bulk editing metadata manawydan Library Management 5 06-17-2013 08:22 AM


All times are GMT -4. The time now is 04:46 AM.


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