Regexp and Action Groups

Hi everyone! I am trying to setup an action group that:

  • if a tag is under date, move it to year
  • replace year if is formatted in any other way other than YYYY

I am very confused on how to leverage the scripting capabilities and would appreciate some help! :smiley:

You'd use two actions in an action group to realize this:

  1. Format tag field for YEAR with $if2(%date%,%year%) This copies the DATE to the YEAR field, but only if it's present — otherwise the YEAR field is left untouched.

  2. Replace with Regular Expression for field YEAR with .*?(\d{4}).* as regular expression and $1 as replacement. This takes any 4-digit number from the YEAR field and forgets the rest.

You can go even further and also remove the DATE field with an additional action, but sometimes it's good to keep the extra information.

2 Likes

Hey Florian, thanks for the examples. I just tried them and they work very well!

However, I'm having troubles in understanding the YEAR vs DATE fields. My understanding is that Mp3Tag maps YEAR to DATE under the hood. No matter the input or the edits, everything always ends up in the DATE field. Is my assumption correct?

BTW, this works well for me! I'm just trying to understand more :slight_smile:

The automatic mapping is only done with VorbisComments which are used with FLAC, Ogg, and Opus.

It mainly exists to respect the convention of using DATE with those file formats, but provide a common field YEAR in Mp3tag that can be used across different file formats.

Gotcha!

One last detail: I loaded a FLAC, and this doesn't work

But if I split those actions into two separate groups and run them one after the other, they work well! Am I missing anything here, or doing something wrong?

I'm not sure what you mean by "this doesn't work" :slight_smile: If it's related to the PUBLISHER field, I'd have a look at the extended tag dialog via Cmd+T and verify it's there.

If it's related to the YEAR, I'd need more information.

Sorry! :smiley:

The Publisher to Label action works well, but the second action related to the regexp on the Year is not triggered.

The second action works well individually, when placed into a group of its own, but not when paired with the first one.

Looking closely, it seems that there is a trailing space at the end of the regular expression. Can you check?

HA! That was it. Sorry for the confusion Florian, it definitely was my fault haha!

No problem, happy it's working now :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.