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


#1

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


#2

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.


#3

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


#4

Works Great!!! Thanks so much!


#5

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!


#6

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


#7

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.


#8

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!