# Question on Actions - Is there a "Switch Case" like function?

**URL:** <https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417>\
**Category:** Support\
**Created:** [October 27, 2018, 5:37pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417 "2018-10-27T17:37:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CRSounds](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CRSounds](https://community.mp3tag.de/u/CRSounds)\
**Post date:** [October 27, 2018, 5:37pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/1 "2018-10-27T17:37:10Z")

</div>

Hello,  
This is my first post. I am trying to update my music files with two types of Key Information. I am a DJ and want to show both Camelot and Major/Minor Keys in my Tags. To do that I am using a Tag field that I do not use and re-purposing it. The unused field is ORIGARTIST. Which will hold my Camelot Key, the %initialkey% tag will hold my Major/Minor. My problem is that I had to create 25 different actions to allow me to do all of the conversions.

Assume that I initially have the Camelot Key in the %initialkey% tag. I created my first action to copy %initialkey% to ORIGARTIST. That code is:

> ```
> [#0]
> T=5
> F=ORIGARTIST
> 1=%initialkey%
> 
> ```

Next I have 24 Conversion Actions depending on the Camelot Key (1A,1B to 12A, 12B) I look to see if the ORIGARTIST matches the Camelot Key I am looking for and if so I replace the %initialkey% with the corresponding Major/Minor Key. That code is (for Camelot Key 1B):

> ```
> [#0]
> T=5
> F=INITIALKEY
> 1=$if($eql(%origartist%,'1B'),'B',%origartist%)
> 
> ```

So in order for me to tag a number of files I have to do the Copy Action, then sort all of the files by Camelot Key, then select the files with the same key, and run that Key's action.

Is there a way to combine all of my conversion Actions into one like a Switch Case (in the C programming language)?

For instance

> ```
> Switch (CAMELOTKEY)
> {
> case 1A:
> initialkey=Abm;
> break;
>     
> case 1B:
> initialkey=B;
> break;
>     
> etc.
> etc.
> }
> 
> ```

Sorry for the long winded explanation, but I wanted to be clear. Any thoughts on how I could do this with the current Action interface?

Thanks In Advance!  
Carlton

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 27, 2018, 9:03pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/2 "2018-10-27T21:03:07Z")

</div>

If you have pairs of values, like  
B/1B  
Abm/1A

You can use an action of the type "Format value" for the target field with  
Format string: $replace(%camelotkey%,1A,Abm,1B,B)

Add the pairs of values in the format string.

---

<div class="post-metadata">

**Author:** ![CRSounds](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CRSounds](https://community.mp3tag.de/u/CRSounds)\
**Post date:** [October 27, 2018, 9:36pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/3 "2018-10-27T21:36:14Z")

</div>

Are you saying that the $replace function can do all values at once? I will have to look into that. Thanks Much!

---

<div class="post-metadata">

**Author:** ![CRSounds](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CRSounds](https://community.mp3tag.de/u/CRSounds)\
**Post date:** [October 27, 2018, 10:03pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/4 "2018-10-27T22:03:18Z")

</div>

Works Great!!! Thanks so much!

---

<div class="post-metadata">

**Author:** ![CRSounds](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CRSounds](https://community.mp3tag.de/u/CRSounds)\
**Post date:** [October 27, 2018, 10:52pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/5 "2018-10-27T22:52:21Z")

</div>

Oops...I seem to have found a problem that I'm hoping you can help resolve, here is the code I am using for the Action

> ```
> [#0]
> T=5
> F=INITIALKEY
> 1=$replace(%origartist%,1A,Abm,1B,B,2A,Ebm,2B,F#,3A,Bbm,3B,Db,4A,Fm,4B,Ab,5A,Cm,5B,Eb,6A,Gm,6B,Bb,7A,Dm,7B,F,8A,Am,8B,C,9A,Em,9B,G,10A,Bm,10B,D,11A,F#m,11B,A,12A,Dbm,12B,E)
> 
> ```

The problem I am seeing is that when the function comes up to the 11A search, it sees the 1A first and gets confused and uses the 1A replacement. How can i make the replace specifically look for 11A instead of 1A? I tried quotes and the but neither helped...

Again Thanks in Advance!

---

<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:** [October 28, 2018, 9:26am UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/6 "2018-10-28T09:26:41Z")

</div>

You can try reordering the replacements so that 11A is replaced before 1A.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [October 28, 2018, 11:05am UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/7 "2018-10-28T11:05:59Z")

</div>

> [@CRSounds](#):
>
> How can i make the replace specifically look for 11A instead of 1A

The behaviour is just like with a set of actions in an action group where you have to reorder the actions so that each pair of search and replace strings is treated only once.

---

<div class="post-metadata">

**Author:** ![CRSounds](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CRSounds](https://community.mp3tag.de/u/CRSounds)\
**Post date:** [October 28, 2018, 4:28pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/8 "2018-10-28T16:28:53Z")

</div>

Thanks Florian, Reordering did the trick! Much Appreciated. I just sent in another donation yesterday. I have done this for the last few years as I really appreciate this software!

---

<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:27pm UTC](https://community.mp3tag.de/t/question-on-actions-is-there-a-switch-case-like-function/43417/9 "2026-02-09T12:27:44Z")

</div>


