Rename album name if the name does not contain "volume"

Tags: #<Tag:0x00007f7cfb777728> #<Tag:0x00007f7cfb777610> #<Tag:0x00007f7cfb7774f8>

I want add a trigger script in MusicBrainz Picard to rename my album name for Various Artists.

For example, I have this album names:

  • Various Artists - Dream Dance, Vol. 53
  • Various Artists - Big City Beats 9
  • Various Artists - Big City Beats, Vol. 12
  • Various Artists - Future Trance 48

Now, I want to rename this album names to:

  • Various Artists - Dream Dance, Volume 53
  • Various Artists - Big City Beats, Volume 9
  • Various Artists - Big City Beats, Volume 12
  • Various Artists - Future Trance, Volume 48

How can I realize it with regular expressions?

Here a my solution, but it does not work.
$set(album,$replace(%album%,Various Artists - \([Dream Dance|Big City Beats|Future Trance]\) \([0-9]{1\,2},Various Artists - %1%\, Volume %2%))


I see two possible issues. First, you have nothing to match (and discard) a “Vol.” if it’s between the title and the number. More importantly, the [] around the series titles mean to treat them as a character set, not a literal string. I’d try removing those.

Still learning the scripting syntax here myself. A couple more very important issues with your script:

  • You need to use $rreplace() to do regex matching, $replace() just does literal string matching
  • Backreferences to the captured patterns are referenced using \1 not %1%; however it seems you have to escape the backslash, so you’d write \\1 .

I think you want something like this:

$set(album,$rreplace(%album%,Various Artists - \(Dream Dance|Big City Beats|Future Trance\).* \([0-9]{1\,2},Various Artists - \\1\, Volume \\2))

1 Like

yes I want something like this, but it does not work even after the bug fix with missing brackets in your example.

Fixed version:
$set(album,$rreplace(%album%,Various Artists - \(Dream Dance|Big City Beats|Future Trance\).* \([0-9]{1\,2}\),Various Artists - \\1\, Volume \\2))

If tried to use a simple regexp test, if regexp works on my Picard version, but when I run this simple script on an album, it does not change my album name. So i think, maybe it’s a bug fix in music picard?

regexp test:
$set(album,$rreplace(%album%,\(.*\),\\1 Test))


Hmm, that’s interesting. I tried it with some cds that I had to hand (and with a silly misspelling to make it obvious if it was working):

$set(album,$rreplace(%album%,\(Genius of Modern Music|The Eminent Jay Jay Johnson\).* \([0-9]{1\,2}\),\\1 - Voloom \\2))

…and this worked for me. So possibly it’s a matter of when the scripts are applied? There’s a previous forum thread on that issue.

1 Like

Hello, I don’t known why, but now my script works fine.

Thank you very much!