Hi All,
my question is the following:
in ALBUM I would replace "CD1" with "CD" and the content of %discnumber%.
Example: American Beauty CD1 (Remaster) should became American Beauty CDx (Remaster), where x is the content of the Tag %discnumber%.
I've tried with Replace function but I did'nt find the operator that allow me to append the content of a Tag.
Many thanks in advance for you replay
You could try an action of the type "Format value" for ALBUM with
Format string: $regexp(%album%,(.*CD)\d+(.*),$1%discnumber%$2)
Thanks for your help, but your suggestion cancels everything before CD1: "American Beauty CD1 (Remaster)" became "(Remaster)"
In other words I would replace the number "1" inside ALBUM with the content of tag %discnumber%, leaving the rest of the text intact.
I hope to be clear enough.
Thank again
Then please show us the real album title.
Because:
$regexp('American Beauty CD1 (Remaster)',(.*CD)\d+(.*),$1%track%$2)
becomes American Beauty CDA05 (Remaster)
(I used TRACK instead of DISCNUMBER as DISCNUMBER was also filled with 1 so I would not see a difference).
So I would say: works as requested.
The result you shown me is fine, but applied to my text "Band In Italy CD1 - Canzoni Di Ieri, Canzoni Per Oggi" returns " - Canzoni Di Ieri, Canzoni Per Oggi"
No.
The test in Convert>tag-tag with
$regexp('Band In Italy CD1 - Canzoni Di Ieri, Canzoni Per Oggi',(.*CD)\d+(.*),$1%track%$2)
leads to
"Band In Italy CDA05 - Canzoni Di Ieri, Canzoni Per Oggi
(where my field TRACK has the contents A05)
Please note that the string is case sensitive. So it is a difference if you have CD, Cd or cd.
You could modify the regular expression to
$regexp('Band In Italy CD1 - Canzoni Di Ieri, Canzoni Per Oggi',(.*Cd)\d+(.*),$1%track%$2,1)
I'm sorry, I've cut your function and pasted to Format string but the result is not what you show me. I'm using Mp3Tag 3.04a.
Anyway I don't want to waste your time, you show me the path and I will study the syntax.
I really appreciate your suggestion. Thank you very much for your patience.
That's the difference. The expression does not work as intended if the content of DISCNUMBER is a digit.
Fascinatingly, this one works:
$regexp('American Beauty CD1 (Remaster)',(^.*CD)\d+(.*),$1 %track%$2)
(with an extra blank following $1)
Thank you everybody!
Yesterday evening I tried to understand the syntax of your regexp function without success.
Your last suggestion finally works, but there is a blank between CD and the digit contained in DISCNUMBER.
I made several test, modifying the syntax of the function without success. So far I've understood the following:
$regexp(%Album%,(^.CD)\d+(.),$1 %discnumber%$2)
*(^.CD) means from the start of the line up to CD
\d+(.*) means any number
$1 Does it mean end of line 1?
$2 Does it mean end of line 2?
The use of $1 and $2 are not clear to me
Thank you very much for your support, in any case I've learned something more about regexp
not quite.
\d+
means there must be a number or any length
but the important bit is the (.*)
as this means "and remember any further string".
As there is already the first string up to "CD" enclosed in brackets, it means "remember this as the first string".
The first remembered string is addressed by $1
The second remembered string is addressed as $2
The regular expression has 3 parts:
"Part1,Part2,Part3"
Part1 is the source
Part2 is the definition of the pattern
Part3 is the instruction what to do with the defined pattern.
In this case the definition of the pattern was "Take a string up to CD and remember it, use a number to separate this from the second remembered string."
The instruction, finally, was: "take string1, insert the contents of %discnumber% then take string 2"
I am a little astonished that the regular expression parser had problems to evaluate the "$1%".
Hmmm.
It could be that the parser, instead of going left to right in the expression first inserted the contents of %discnumber%, e.g. a "1", so that the instruction became "$11" where the second "1" was already the contents of %discnumber% - but as we never addressed 11 sub strings, this address was empty and nothing got inserted. And as the devil is a squirrel (German proverb) I randomly chose an example where the contents was not "1" but "A05" - and "$1A" perfectly resolves to the first sub string address.
I am not sure if this is a bug or intended design ...