# Copy values between fields with regexp

**URL:** <https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058>\
**Category:** Support\
**Created:** [October 30, 2012, 11:20am UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058 "2012-10-30T11:20:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigpatik](https://community.mp3tag.de/user_avatar/community.mp3tag.de/craigpatik/32/13051_2.png) [@craigpatik](https://community.mp3tag.de/u/craigpatik)\
**Post date:** [October 30, 2012, 11:20am UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058/1 "2012-10-30T11:20:10Z")

</div>

I have a bunch of files with generic album names like "\_misc". In the comment field, they have the real album name, formatted as "album[REAL\_NAME]". There may be other text in the comment field before/after the album[] declaration.

So I want to run this regexp on the comment field: album[([^]]+)] and place the match ($1) in the album field, overwriting its current value. How can I do this?

---

<div class="post-metadata">

**Author:** ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)\
**Post date:** [October 30, 2012, 3:40pm UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058/2 "2012-10-30T15:40:46Z")

</div>

Make a [new action](https://community.mp3tag.de/t/967/1):

_Action type:_ **Format value**  
_Field:_ **ALBUM**  
_Format string:_ **$regexp(%comment%,'album[([^]]+)]',$1)**

---

<div class="post-metadata">

**Author:** ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)\
**Post date:** [October 30, 2012, 5:20pm UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058/3 "2012-10-30T17:20:15Z")

</div>

That leaves any text before or after the "album[...]" match, which I would think isn't wanted. The following only keeps the text within the square brackets:

**$regexp(%comment%,'^._album[([^]]+)]._$',$1)**

---

<div class="post-metadata">

**Author:** ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)\
**Post date:** [October 30, 2012, 7:29pm UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058/4 "2012-10-30T19:29:57Z")

</div>

> [@craigpatik](#):
>
> I have a bunch of files with generic album names like "\_misc". In the comment field, they have the real album name, formatted as "album[REAL\_NAME]". There may be other text in the comment field before/after the album declaration.  
> So I want to ... place the match ... in the album field, overwriting its current value. How can I do this?

Here is a proposal using the action 'Guess values' ...

Action: Guess values  
Source format: **%COMMENT%**  
Guessing pattern: **%DUMMY%album[%ALBUM%]%DUMMY%**

Example ...  
From:  
COMMENT=... formatted as "album[REAL\_NAME]". There may be other text ...  
To:  
ALBUM=REAL\_NAME

DD.20121030.2128.CET

---

<div class="post-metadata">

**Author:** ![craigpatik](https://community.mp3tag.de/user_avatar/community.mp3tag.de/craigpatik/32/13051_2.png) [@craigpatik](https://community.mp3tag.de/u/craigpatik)\
**Post date:** [October 30, 2012, 7:55pm UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058/5 "2012-10-30T19:55:49Z")

</div>

> [@JJ Johnson](#):
>
> **$regexp(%comment%,'^._album[([^]]+)]._$',$1)**

That worked, thank you everyone!

---

<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:** [February 9, 2026, 12:24pm UTC](https://community.mp3tag.de/t/copy-values-between-fields-with-regexp/14058/6 "2026-02-09T12:24:08Z")

</div>


