Renaming Macro with a variable (changing) suffix

I wasn’t sure exactly what I am after in terms of programming terminology, so excuse me if this has been discussed, I’m sure it probably has. I am working in Pro Tools audio editor. I am trying to create a macro to batch rename tracks. For example, I have one version working quite well, where it take a name and add a number and then increment that number with each track for the specified number of tracks.

What I am trying to do now is rename tracks where each one is a different channel of surround sound. So I want the suffix to be a channel label such as L, C, R, Ls, Rs, or LFE (left, center, right, left surround, right surround, LFE). They are always in that order but sometimes I only need it to label three or maybe five tracks (you could think of them as rows or cells in excel). So I am trying to create a macro that will prompt me for the number of channels and then it would label each one accordingly. So for 3 it would label 3 tracks “L”, “C”, and “R”. 1 track would only be “L.” 6 would six tracks and so on.

So basically I want to have a list of suffixes and then tell it to access and type out the requested number of entries in that list. I know enough programming to know that this is pretty basic stuff, but I’m trying to do this within KM and haven’t yet ventured into scripting. Is this possible? Thank you!

I wasn't able to tell for sure from your post whether or not you actually wanted the channel labels separated by commas like this, but this sample macro should still demonstrate one way of accomplishing this task in KM and will hopefully point you in the right direction. If this doesn't answer your question, please let us know, and please also include the macro itself, along with a precise example of what you would like the outputted channel labels to look like.

Rename Tracks.kmmacros (4.5 KB)

Given you already have this working for plain numbers, it seems you need a way to convert a numerical index to one of your six labels. You can use the new (in 7.2+) array facility of the Variable token:

Peter thank you so much! This worked perfectly! This is exactly what I was after. Being able to access parts of an array will really open up new possibilities for me. This is excellent. This is what I ended up with:

I select the first track in the group of tracks I want to rename. I select the rename command and then fire off the macro. It prompts me as to what I want to rename the tracks to be and how many there are to rename. Then it will rename the track and then repeat the give amount of times, typing in the correct suffix (index in the array). (The command+down, commandA, delete and are all commands to navigate to the next track's name, select it and delete it, just FYI)

Thanks so much!

1 Like

That is what I aim for when I implement features!

Hard to believe I've been using the heck out of this and other macros based on this topic for a going on a year and a half.

Peter, quick follow up question. Is is possible to calculate the number of entries in the variable's array. So in this instance there are 6 entries and I can cycle through them. Is there a built in variable or calculation that will return 6. So if I were to update my "Labels" variable to "L,C,R" it would return 3?

I've come up in a situation using repeats and it'd be nice to to base the number of repeats on the number of entries into my label variable (rather than hard coded).

Thanks again for the continued development of this amazing software.

Yes, %Variable%VarName[0]% will return the length of the array (ie 3 in this case).

AWESOME! Thank you for the quick response. Works perfectly. Thank you

1 Like