View Single Post
Old 03-16-2013, 05:56 PM   #1
manawydan
Connoisseur
manawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toys
 
Posts: 95
Karma: 5854
Join Date: Aug 2011
Device: none
Regex help pls for bulk editing metadata

I have tried to make sense of the regex help in the manual but can't do it on my own.

I need help with two things.
Both are for bulk editing metadata (title).
Sorry if I mix terms here, I have very little knowledge about this.

Calibre version is 0.9.15.

1.
I can remove parts of a title with the replace-function if the string is always the same.
E.g.
Castle 03. Castle Kidnapped
Castle 04 - Ever after
I can remove Castle 0

However this would leave different numbers as well as characters (. - space).
E.g.
3. Castle Kidnapped
4 - Ever after

What is the regular expression to remove varying numbers too and could this be combined in one regex (remove "castle" + any number with leading zero)?
Dots etc. could be removed with search-replace if needed.

2.
Sometimes I want to bulk remove part of a title.
E.g. everything in brackets
(Castle 3) Castle Kidnapped
Castle lost (a castle novella)

How to do this (the text within brackets is not the same)?

What if the string you want to remove is not enclosed by the same character?

E.g.
Castle 3; Castle Kidnapped
Castle lost - a castle novella

You would have to use an expression like "remove everything left from ;" or "remove everything after -", correct? But how?

Can you use a phrase as "seperator"?
If a title is like this

Castle 3 Kidnapped and loving it
Kidnapped and loving it a castle novella

Is it possible to use "kidnapped and loving it" as string and remove text left or right of it?

Thanks in advance.

Last edited by manawydan; 03-16-2013 at 05:58 PM.
manawydan is offline   Reply With Quote