# Regexp and Action Groups

**URL:** <https://community.mp3tag.de/t/regexp-and-action-groups/52475>\
**Category:** Mac\
**Created:** [March 23, 2021, 1:16am UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475 "2021-03-23T01:16:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![markoit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@markoit](https://community.mp3tag.de/u/markoit)\
**Post date:** [March 23, 2021, 1:16am UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/1 "2021-03-23T01:16:23Z")

</div>

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! 😃

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [March 23, 2021, 6:19am UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/2 "2021-03-23T06:19:50Z")

</div>

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.

 ![ActionGroup-MoveDATEtoYEAR](https://community.mp3tag.de/uploads/default/original/2X/f/f200947aa69672a662cb90736fa5da00947c1193.png)

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.

---

<div class="post-metadata">

**Author:** ![markoit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@markoit](https://community.mp3tag.de/u/markoit)\
**Post date:** [March 23, 2021, 7:20pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/3 "2021-03-23T19:20:25Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [March 23, 2021, 7:25pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/4 "2021-03-23T19:25:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![markoit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@markoit](https://community.mp3tag.de/u/markoit)\
**Post date:** [March 23, 2021, 7:47pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/5 "2021-03-23T19:47:17Z")

</div>

Gotcha!

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

 ![image](https://community.mp3tag.de/uploads/default/original/2X/1/1e6344e88250a029fa22bd4cf1c9cac164d44275.png)

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?

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [March 23, 2021, 7:50pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/6 "2021-03-23T19:50:28Z")

</div>

I'm not sure what you mean by "this doesn't work" 🙂 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.

---

<div class="post-metadata">

**Author:** ![markoit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@markoit](https://community.mp3tag.de/u/markoit)\
**Post date:** [March 23, 2021, 7:56pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/7 "2021-03-23T19:56:34Z")

</div>

Sorry! 😃

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.

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [March 23, 2021, 8:09pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/8 "2021-03-23T20:09:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![markoit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@markoit](https://community.mp3tag.de/u/markoit)\
**Post date:** [March 23, 2021, 8:16pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/9 "2021-03-23T20:16:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [March 23, 2021, 8:17pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/10 "2021-03-23T20:17:09Z")

</div>

No problem, happy it's working now 🙂

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [April 22, 2021, 8:18pm UTC](https://community.mp3tag.de/t/regexp-and-action-groups/52475/11 "2021-04-22T20:18:05Z")

</div>

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