# Problem with appending COMMENT field with letters

**URL:** https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916
**Category:** Support
**Created:** [January 10, 2012, 4:47pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916 "2012-01-10T16:47:34Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [January 10, 2012, 4:47pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/1 "2012-01-10T16:47:34Z")

</div>

I'm having problems when I have letters in the COMMENT field and I want to append the INITIALKEY field into it. If the COMMENT field contains numbers it works fine but with letters it deletes them. What i have is:  
  
 _**Before (Works fine):**  
INITIALKEY: 4A  
COMMENT: 5_

 **Result:**

INITIALKEY: 4A  
COMMENT: 4A - 5

_**Before (Does NOT work):**_ 

_INITIALKEY: 4A  
COMMENT: ANY TEXT HERE_

 _ **Result:** _ 

_INITIALKEY: 4A_

 

_```
COMMENT: 4A<!--colorc--></span><!--/colorc--></i><!--coloro:#000000--><span style="color:#000000"><!--/coloro--><i> [<b>Notice it deletes '</b></i><!--colorc--></span><!--/colorc--><i><!--coloro:#000000--><span style="color:#000000"><!--/coloro--><b>ANY TEXT HERE'</b>]<!--colorc--></span><!--/colorc--></i>_

_```_

 

_Im using the following actions:  
Name of action group: **For&mat#INITIALKEY Key to Camelot Notation** _

 

_Action #1:  
Action type: **Replace**  
Field: **INITIALKEY**  
Original: **B Major**  
Replace with: **1B** _

 _[] only as whole word_

_[] case-sensitive comparison_

 

_ **\>\>\>\>\>\>\>Action #1 - #24 change keys to Camelot Notation\>\>\>\>\>\>\>\>** _

 

_Action #25:  
Action type: **Format value**  
Field: **COMMENT**  
Formatstring: **%initialkey% - %comment%** _

 

_Action #26:  
Action type: **Replace with regular expression**  
Field: **COMMENT**  
Regular expression: **^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)**  
Replace matches with: **$1$2** _

 _[] case-sensitive comparison_ 

_I've tried using it without action #26 which just cleans up the COMMENT field but it still deletes text and not numbers._

 

_I was just wondering what workaround I could use for action #25?_

---

<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: [January 10, 2012, 5:06pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/2 "2012-01-10T17:06:22Z")

</div>

I just tried it and your action #25 works fine for me. I used the exact same field names and values.

What happens if you execute it alone, without the prior 24 actions in the group?

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [January 10, 2012, 5:56pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/3 "2012-01-10T17:56:35Z")

</div>

yes, Sorry I should of mentioned I tested it on its own and it works just fine. I Have also tried separating the actions with no joy.

I have placed the attached format action group above the replace and reg exp action group in the action list tree. (See attached).

I'm not sure if its a bug in the programme or what??

[For\_mat\_INITIALKEY\_Key\_to\_Camelot\_Notation\_\_1\_.mta](https://community.mp3tag.de/uploads/default/original/2X/f/ffcf860cfed814233922ad9e6464d4308293c5e0.mta) (55 Bytes)

[For\_mat\_INITIALKEY\_Key\_to\_Camelot\_Notation\_\_2\_.mta](https://community.mp3tag.de/uploads/default/original/2X/5/5441ed859f9125f56db8889e4056bddfe0b0bdad.mta) (2.67 KB)

![](https://community.mp3tag.de/uploads/default/original/2X/9/9fb67fde31fbfcedd452cf31b465795d6dc5eada.jpg)

---

<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: [January 10, 2012, 6:21pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/4 "2012-01-10T18:21:15Z")

</div>

From a debugging standpoint, if you haven't done it already, see what you have if you end the action group after action #24. Are you certain that the INITIALKEY and COMMENT fields contain the values that you think they do going into action #25? Particularly the COMMENT field, given the behavior that you describe.

If indeed it's a program bug and the execution of the 20+ actions in one action group could have something to do with it, try breaking the group down into several logical parts.

---

<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: [January 10, 2012, 6:41pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/5 "2012-01-10T18:41:59Z")

</div>

I took your long action group, and replaced the last action with the one that combines the fields.

_Action type:_ **Format value**  
_Field:_ **COMMENT**  
_Format string:_ **%initialkey% - %comment%**

And it still works as expected on my system. Could it have something to do with the unicode characters? Does it fail when the replaced strings do not contain one of these?

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [January 11, 2012, 1:13am UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/6 "2012-01-11T01:13:22Z")

</div>

I have found the problem! Silly me. I have the following action which is above my new action which strips the comment field if it doesn't start with a digit as I always format my COMMENT tag like '4A - 5' 4A being the Camelot Notation and the 5 the rating of the track.

_Action type:_ **Replace with regular expression**  
_Field:_ **COMMENT**  
_Regular expression:_ **^[^\d]+.+**  
_Replace matches with:_

[] case-sensitive comparison

So for anyone out there who wants to change the INITIALKEY tag from F♯ Major to 2B and append it to the start of the COMMENT tag then here is the working action.

_Name of action group:_ **For&mat#INITIALKEY Key to Camelot Notation**

Action #1:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **B Major**  
_Replace with:_ **1B**

[] only as whole word

[] case-sensitive comparison

Action #2:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **F♯ Major**  
_Replace with:_ **2B**

[] only as whole word

[] case-sensitive comparison

Action #3:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **D♭ Major**  
_Replace with:_ **3B**

[] only as whole word

[] case-sensitive comparison

Action #4:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **A♭ Major**  
_Replace with:_ **4B**

[] only as whole word

[] case-sensitive comparison

Action #5:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **E♭ Major**  
_Replace with:_ **5B**

[] only as whole word

[] case-sensitive comparison

Action #6:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **B♭ Major**  
_Replace with:_ **6B**

[] only as whole word

[] case-sensitive comparison

Action #7:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **F Major**  
_Replace with:_ **7B**

[] only as whole word

[] case-sensitive comparison

Action #8:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **C Major**  
_Replace with:_ **8B**

[] only as whole word

[] case-sensitive comparison

Action #9:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **G Major**  
_Replace with:_ **9B**

[] only as whole word

[] case-sensitive comparison

Action #10:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **D Major**  
_Replace with:_ **10B**

[] only as whole word

[] case-sensitive comparison

Action #11:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **A Major**  
_Replace with:_ **11B**

[] only as whole word

[] case-sensitive comparison

Action #12:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **E Major**  
_Replace with:_ **12B**

[] only as whole word

[] case-sensitive comparison

Action #13:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **A♭ Minor**  
_Replace with:_ **1A**

[] only as whole word

[] case-sensitive comparison

Action #14:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **E♭ Minor**  
_Replace with:_ **2A**

[] only as whole word

[] case-sensitive comparison

Action #15:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **B♭ Minor**  
_Replace with:_ **3A**

[] only as whole word

[] case-sensitive comparison

Action #16:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **F Minor**  
_Replace with:_ **4A**

[] only as whole word

[] case-sensitive comparison

Action #17:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **C Minor**  
_Replace with:_ **5A**

[] only as whole word

[] case-sensitive comparison

Action #18:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **G Minor**  
_Replace with:_ **6A**

[] only as whole word

[] case-sensitive comparison

Action #19:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **D Minor**  
_Replace with:_ **7A**

[] only as whole word

[] case-sensitive comparison

Action #20:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **A Minor**  
_Replace with:_ **8A**

[] only as whole word

[] case-sensitive comparison

Action #21:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **E Minor**  
_Replace with:_ **9A**

[] only as whole word

[] case-sensitive comparison

Action #22:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **B Minor**  
_Replace with:_ **10A**

[] only as whole word

[] case-sensitive comparison

Action #23:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **F♭ Minor**  
_Replace with:_ **11A**

[] only as whole word

[] case-sensitive comparison

Action #24:  
_Action type:_ **Replace**  
_Field:_ **INITIALKEY**  
_Original:_ **D♭ Minor**  
_Replace with:_ **12A**

[] only as whole word

[] case-sensitive comparison

Action #25:  
_Action type:_ **Format value**  
_Field:_ **COMMENT**  
_Formatstring:_ **%initialkey% - %comment%**

Action #26:  
_Action type:_ **Replace with regular expression**  
_Field:_ **COMMENT**  
_Regular expression:_ **^\s+-\s+|^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)**  
_Replace matches with:_ **$1$2**

[] case-sensitive comparison

---

<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: [January 11, 2012, 6:26am UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/7 "2012-01-11T06:26:36Z")

</div>

> [@stevehero](#):
>
> ...  
> Action #26:  
> _Action type:_ **Replace with regular expression**  
> _Field:_ **COMMENT**  
> _Regular expression:_ **^\s+-\s+|^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)**  
> _Replace matches with:_ **$1$2**
> 
> [] case-sensitive comparison

Please explain, what is the purpose of Action #26 and how does it work?

If you want to detect a 'Camelot string' then you can use this regular expression:  
((?:[1-9]|1[0-2])[AB])

Be aware that you fill the tag-field INITIALKEY with bad data, when filling it with a 'Camelot string'.  
The standard rules for ID3v2.3 and ID3v2.4 defines the frame TKEY as:  
TKEY  
The 'Initial key' frame contains the musical key in which the sound starts. It is represented as a string with a maximum length of three characters. The ground keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys represented with "b" and "#". Minor is represented as "m". Example "Cbm". Off key is represented with an "o" only.

It would be a good practical advice to save already existing 'musical key string' into a user-defined backup tag-field _before_ overwriting the tag-field INITIALKEY with 'bad data'.

DD.20120111.0854.CET

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [January 12, 2012, 4:24pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/8 "2012-01-12T16:24:09Z")

</div>

> [@DetlevD](#):
>
> Please explain, what is the purpose of Action #26 and how does it work?

Once the format has been done the following cleans up the COMMENT tag.

**^\s+-\s+|^\s+-\s+$**** |\s+-\s+$****|\s+-\s+\d{1,2}[A-B]\s+-\s+$****|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)**

**^\s+-\s+** deletes 'startofstring'whitespace'-'whitespace' if only COMMENT is present.

**^\s+-\s+$** deletes 'startofstring'whitespace'-'whitespace'endofstring' if both COMMENT and INITIALKEY tag are empty.

**\s+-\s+$** deletes 'whitespace'-'whitespace'endofstring' if only INITIALKEY is present.  
**\s+-\s+\d{1,2}[A-B]\s+-\s+$** removes the extra INITIALKEY and 'whitespace'-'whitespace' after format from end of string.  
**\s+-\s+\d{1,2}[A-B]$** same sort of thing basically only just the INITIALKEY from end of string.  
**^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)** captures and sorts the COMMENT tag the way it should be formatted.

> [@DetlevD](#):
>
> If you want to detect a 'Camelot string' then you can use this regular expression:  
> ((?:[1-9]|1[0-2])[AB])

How is broken down?

> [@DetlevD](#):
>
> Be aware that you fill the tag-field INITIALKEY with bad data, when filling it with a 'Camelot string'.  
> The standard rules for ID3v2.3 and ID3v2.4 defines the frame TKEY as:  
> TKEY  
> The 'Initial key' frame contains the musical key in which the sound starts. It is represented as a string with a maximum length of three characters. The ground keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys represented with "b" and "#". Minor is represented as "m". Example "Cbm". Off key is represented with an "o" only.

So:  
A sharp minor is A#m  
A flat offkey is Abo

Correct?

---

<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: [January 12, 2012, 5:49pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/9 "2012-01-12T17:49:38Z")

</div>

> [@stevehero](#):
>
> Once the format has been done the following cleans up the COMMENT tag. ...

stevehero, thank you for the effort to describe the regular expression so colourful.  
Still it is not clear to me how the content of the COMMENT tag-field looks like, i. e. the different variations of text content, what the regexp should handle.  
It seems to be a very special case for your own purposes?  
Can you provide some samples to let me understand what the big regular expression can resolve?

> [@stevehero](#):
>
> A sharp minor is A#m  
> A flat offkey is Abo  
> Correct?

I understand the term 'off key', stored in tag-field INITIALKEY as the single letter 'o', this way:  
The related sound has nothing to do with the musical theory of western music and their melody scales.  
The sound is simply off from any key.

DD.20120112.1950.CET

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [January 16, 2012, 6:58pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/10 "2012-01-16T18:58:38Z")

</div>

> [@DetlevD' date='Jan 12 2012](#):
>
> stevehero, thank you for the effort to describe the regular expression so colourful.  
> Still it is not clear to me how the content of the COMMENT tag-field looks like, i. e. the different variations of text content, what the regexp should handle.  
> It seems to be a very special case for your own purposes?  
> Can you provide some samples to let me understand what the big regular expression can resolve?

It changes the **COMMENT** field from:  
  
 12A - 12A - Any word character **TO** _(NEED REG EXP TO MATCH THIS)_  
 12A - Any word character (REPLACE WITH '$1$2')  
  
**^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)**  
 Text representation of regular Exp:  
 **^(12A - )12A - (Any word character)**  
  
**^** Anchors search to start of string.  
**_(_** Start capture no#1.  
**\d{1,2}[A-B]\s+-\s+** finds '1A - _'  
**)**_ End capture no#1.  
**\d{1,2}[A-B]\s+-\s+** finds '1A - '.  
**_(_** Start capture no#2.  
**_\w_**** +** Captures word characters.  
**_)_** End capture no#2.

> [@DetlevD' date='Jan 12 2012](#):
>
> I understand the term 'off key', stored in tag-field INITIALKEY as the single letter 'o', this way:  
> The related sound has nothing to do with the musical theory of western music and their melody scales.  
> The sound is simply off from any key.

I know:  
A sharp minor is A#m

But how is:  
A sharp major represented?

---

<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:23pm UTC](https://community.mp3tag.de/t/problem-with-appending-comment-field-with-letters/12916/11 "2026-02-09T12:23:34Z")

</div>


