# Extract COMMENT field in separate fields

**URL:** https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027
**Category:** Support
**Created:** [September 25, 2009, 1:04pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027 "2009-09-25T13:04:45Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![wout\_van\_vucht](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/b9bd4f/32.png) [@wout\_van\_vucht](https://community.mp3tag.de/u/wout_van_vucht)
#### Post date: [September 25, 2009, 1:04pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/1 "2009-09-25T13:04:45Z")

</div>

The COMMENT field of my FLAC-tags looks like:  
COMMENT: 1950s (Songs-DB\_Custom1)  
COMMENT: Cool; Male Vocalists; Female Vocalists; Genius (Songs-DB\_Custom2)  
COMMENT: American (Songs-DB\_Custom3)  
COMMENT: Romantic; Chillout (Songs-DB\_Occasion)

Or COMMENT: 1950s (Songs-DB\_Custom1)\\Cool; Male Vocalists; Female Vocalists; Genius (Songs-DB\_Custom2)\\American (Songs-DB\_Custom3)\\Romantic; Chillout (Songs-DB\_Occasion)

I want those information not in 1 field but in separate fields, like  
COMMENT SONGS-DB\_CUSTOM1: 1950s  
COMMENT SONGS-DB\_CUSTOM2: Cool; Male Vocalists; Female Vocalists; Genius  
COMMENT SONGS-DB\_CUSTOM3: American  
COMMENT SONGS-DB\_OCCASION: Romantic; Chillout

I have tried to make an format value action for this, but without succes.  
Can someone help me?

---

<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: [September 25, 2009, 4:08pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/2 "2009-09-25T16:08:36Z")

</div>

If the COMMENT fields are always in the same order, you can use

_Action type:_ **Guess values**  
_Source format:_ **$regexp($meta\_sep(comment,€),'\s+(Songs-DB.+?)',)**  
_Guessing pattern:_ **%COMMENT SONGS-DB\_CUSTOM1%€%COMMENT SONGS-DB\_CUSTOM2%€%COMMENT SONGS-DB\_CUSTOM3%€%COMMENT SONGS-DB\_OCCASION%**

---

<div class="post-metadata">

### Author: ![wout\_van\_vucht](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/w/b9bd4f/32.png) [@wout\_van\_vucht](https://community.mp3tag.de/u/wout_van_vucht)
#### Post date: [September 25, 2009, 8:22pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/3 "2009-09-25T20:22:09Z")

</div>

It works.  
Thank you very much! 🙂  
I never could have make such an complicated action.

---

<div class="post-metadata">

### Author: ![Infuscu](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/i/278dde/32.png) [@Infuscu](https://community.mp3tag.de/u/Infuscu)
#### Post date: [February 19, 2010, 11:24am UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/4 "2010-02-19T11:24:57Z")

</div>

> [@dano](#):
>
> If the COMMENT fields are always in the same order, you can use
> 
> _Action type:_ **Guess values**  
> _Source format:_ **$regexp($meta\_sep(comment,€),'\s+(Songs-DB.+?)',)**  
> _Guessing pattern:_ **%COMMENT SONGS-DB\_CUSTOM1%€%COMMENT SONGS-DB\_CUSTOM2%€%COMMENT SONGS-DB\_CUSTOM3%€%COMMENT SONGS-DB\_OCCASION%**

Thanks for the solution but the tagger does not always put them in the same order! This happens at times:

Comment field: Italian (Songs-DB\_Custom3); 2000s (Songs-DB\_Custom1); Beautiful; Remix; Male (Songs-DB\_Custom2); Love; Party (Songs-DB\_Occasion)

What would you do in that case? Can you make an universal solution, or can you make another action for such cases? I have tried switching around the numbers in the action you provided but with no luck.

Thanks a lot!

Infuscu

---

<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 3, 2010, 8:47pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/5 "2010-03-03T20:47:49Z")

</div>

> [@Infuscu](#):
>
> What would you do in that case? Can you make an universal solution, or can you make another action for such cases?

I can't think of a universal solution. The best thing is probably to just take dano's Guess values action as an example and adjust it to the changed order of the fields.

---

<div class="post-metadata">

### Author: ![seppl](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@seppl](https://community.mp3tag.de/u/seppl)
#### Post date: [December 27, 2013, 2:42pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/6 "2013-12-27T14:42:19Z")

</div>

In my case, the order of the custom comment fields is always

COMMENT SONGS-DB\_CUSTOM3  
COMMENT SONGS-DB\_CUSTOM1  
COMMENT SONGS-DB\_CUSTOM2  
COMMENT SONGS-DB\_OCCASION

But sometimes one or more fields are missing, so for example it looks like this:

COMMENT SONGS-DB\_CUSTOM3  
COMMENT SONGS-DB\_CUSTOM2

In this case, when not all 4 fields are available, the action command is not working.

How should I adjust the Source format/Guessing pattern so I can extract the comment field in separate custom comment fields no matter how many are available?

Thanks in advance!

---

<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: [December 27, 2013, 7:33pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/7 "2013-12-27T19:33:47Z")

</div>

> [@seppl](#):
>
> In my case, the order of the custom comment fields is always ... But sometimes one or more fields are missing, so for example it looks like this ... In this case, when not all 4 fields are available, the action command is not working.  
> How should I adjust the Source format/Guessing pattern so I can extract the comment field in separate custom comment fields no matter how many are available?Thanks in advance!

Here comes a proposal, which may work for you.  
Note that there are two slightly different proposals for MP3 and FLAC.  
Due to a possible bug in Mp3tag, when working with the FLAC / Vorbis comment tag, there is an additional workaround in the action group for the FLAC tag.

The attached archive file contains ...

- 2 media files of type MP3 with proper tag fields,
- 2 media files of type FLAC with proper tag fields,
- 1 Mp3tag action group for MP3 tagged files,
- 1 Mp3tag action group for FLAC / Vorbis Comment tagged files.

Run the fitting action group against the test files and use the dialog "Extended tags..." to check the results.

[20131227.MP3.FLAC.meta.split.sort.rar](https://community.mp3tag.de/uploads/default/original/2X/a/a0d320f2457f9e31240c19b325ac5a84736a905e.rar) (179 KB)  
DD.20131227.2134.CET

I have changed the Mp3tag action group code in order to get a better view to the program flow.

**TEMP1 \<== '~~~'$meta\_sep(COMMENT,'~~~') TEMP1 \<== $regexp(%TEMP1%,'\s\*\(Songs-DB\_Custom1\)\s\*','~~~1') TEMP1 \<== $regexp(%TEMP1%,'\s\*\(Songs-DB\_Custom2\)\s\*','~~~2') TEMP1 \<== $regexp(%TEMP1%,'\s\*\(Songs-DB\_Custom3\)\s\*','~~~3') TEMP1 \<== $regexp(%TEMP1%,'\s\*\(Songs-DB\_Occasion\)\s\*','~~~4') TEMP2 \<== $regexp(%TEMP1%,'^.\*(?:~~~(.+?)~~~1).\*$','$1') TEMP3 \<== %TEMP3%'~~~'$if($eql(%TEMP1%,%TEMP2%),,%TEMP2%) TEMP2 \<== $regexp(%TEMP1%,'^.\*(?:~~~(.+?)~~~2).\*$','$1') TEMP3 \<== %TEMP3%'~~~'$if($eql(%TEMP1%,%TEMP2%),,%TEMP2%) TEMP2 \<== $regexp(%TEMP1%,'^.\*(?:~~~(.+?)~~~3).\*$','$1') TEMP3 \<== %TEMP3%'~~~'$if($eql(%TEMP1%,%TEMP2%),,%TEMP2%) TEMP2 \<== $regexp(%TEMP1%,'^.\*(?:~~~(.+?)~~~4).\*$','$1') TEMP3 \<== %TEMP3%'~~~'$if($eql(%TEMP1%,%TEMP2%),,%TEMP2%) %TEMP3% ==\> ~~~%COMMENT SONGS-DB\_CUSTOM1%~~~ %COMMENT SONGS-DB\_CUSTOM2% ~~~%COMMENT SONGS-DB\_CUSTOM3%~~~ %COMMENT SONGS-DB\_OCCASION%**

[20131227.COMMENT.meta.split.sort.v1.MP3.mta](https://community.mp3tag.de/uploads/default/original/2X/0/04ea66123c78bd878d9a6bec69e51c9cf498d2b0.mta) (1.16 KB)  
DD.20131229.1630.CET

[20131227.MP3.FLAC.meta.split.sort.rar](https://community.mp3tag.de/uploads/default/original/2X/a/a0d320f2457f9e31240c19b325ac5a84736a905e.rar) (179 KB)

[20131227.COMMENT.meta.split.sort.v1.MP3.mta](https://community.mp3tag.de/uploads/default/original/2X/0/04ea66123c78bd878d9a6bec69e51c9cf498d2b0.mta) (1.16 KB)

---

<div class="post-metadata">

### Author: ![seppl](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@seppl](https://community.mp3tag.de/u/seppl)
#### Post date: [December 28, 2013, 1:23pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/8 "2013-12-28T13:23:21Z")

</div>

Thank you very much, DetlevD, it's working now 🙂  
That looks so complicated, I could have never figured this out by myself.

One more question: is it possible to write an action that opens another action? So I could write an if-statement, that opens either one or the other action group depending on if it's a mp3 or a flac file.

---

<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: [December 28, 2013, 2:45pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/9 "2013-12-28T14:45:21Z")

</div>

> [@seppl](#):
>
> ... One more question: is it possible to write an action that opens another action? So I could write an if-statement, that opens either one or the other action group depending on if it's a mp3 or a flac file.

This is not possible yet.

Here in this case you may use the FLAC file oriented action group, which has the embedded workaround code, for MP3 files too.

DD.20131228.1645.CET

---

<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:21pm UTC](https://community.mp3tag.de/t/extract-comment-field-in-separate-fields/9027/10 "2026-02-09T12:21:49Z")

</div>


