$replacemulti and $cleanmulti don't provide expected result

Hi, I’m new to Picard.

I’m trying to remove the ‘album’ value in %releasetype% when there is more than one value in that tag.

%releasetype% => “album; compilation; broadcast”
$replacemulti(%releasetype%,album,) => “compilation; broadcast”
%releasetype% => “; compilation; broadcast”
$cleanmulti(%releasetype%) => “”
%releasetype% “; compilation; broadcast”
$getmulti(%releasetype%,2) => “broadcast”

As you can see only “$replacemulti(%releasetype%,album,)” output the correct thing yet I cannot get %releasetype% to be clean, i.e, without the "; " at the beginning.
I suppose I could trim that part, but $replacemulti and $cleanmulti should have had already taken care of that.

What’s wrong ?

What happens if you try $setmulti(releasetype,$replacemulti(%releasetype%,album,)) instead? I haven’t checked the code, but it may be that $replacemulti() is returning a string rather than a multi-value variable.

EDIT: Actually, the answer is much simpler than that. See the next message.

1 Like

In this particular case, the problem is that you have entered the argument as %releasetype% rather than releasetype (without the percent signs) so it’s actually trying to clean a variable by the name of “; compilation; broadcast”. Of course, there is no such variable, so an empty string is returned, and the releasetype multi-value is not cleaned. I suspect that this is the cause of the unexpected results.

In this case, remember that the index is zero based, so $getmulti(%releasetype%,2) will actually return the third element. Since you never actually cleaned the %releasetype% multi-value, it still has three elements (the first being empty) so the third element (“broadcast”) is being correctly returned.

2 Likes

Thank you, it works!
BTW: As I mentioned, based on the documentation, replacemulti also does a cleanmulti at the same time so it doing it seperately is not necessary.