Hi,
I am currently doing a lot of work for a client who has mixes regularly for:
R-128
Spotify
SFX_Stem
VO Stem
etc etc.
I have figured out a command for copying and renaming MIX_V1 - MIX_V2 etc. But I haven't found a workable way of adding _R128 to the end of a mix when the mixes get changed to V2 without having to have a button for both MIX_V1_R128 and the another for MIX_V2_R128.
Make sense at all? I am just wondering if there is a way to delete text until a certain character gets reached and then paste the text I want to paste?
- Christian Scheuer @chrscheuer2021-03-12 19:02:34.285Z
Yes certainly. The easiest way to help is if you describe a bit more elaborately: what would be an example of the clip's name before and after (desired rename). The logic would have to be made based on that pattern, and it's not completely clear to me what these would look like based on your original description.
- DDaniel Lozinski @Daniel_Lozinski
Hi Christian,
The before name would be something like: CLIENT_16x9_TVC_MIX_V1_R128
I would like to be able to change the last bit to:
CLIENT_16x9_TVC_MIX_V1_SFX_STEM.
So for this particular one it would be deleting up to the V1 and then typing _SFX_STEM.
The problem I see is that the ends are different lengths so when I want to add _VO_STEM I would run into difficulties.
So my question is - Is there a way to put rules that deleting will only happen until it reaches a certain character like = then type the endings I want then that could be the option?
Below are screenshots of how I do it with Mix versions. but once I have copied and pasted the Movie File name it just adds mix V1. Then for mix V2 I simply copy the existing mix and then use the V2 command and it amends the end. This is the best way I have found to do this. But with this new work there are Versions and differences in file types R128 etc etc so it makes it more complicated.
Best,
Daniel
Christian Scheuer @chrscheuer2021-03-13 18:48:51.314Z
Hi Daniel,
To generally learn how to improve this macro, I would highly recommend watching these two videos to learn how to move from keyboard simulation to UI automation (much better way of automating) in the following 2 videos:
In terms of renaming clips in a good way, I would recommend using an existing
renameClip
function like this one here:Then, to use that function and use the part of the old name up until (and including) the "_V1" part (supporting any version number, not just V1), and append _SFX_STEM, do this:
renameClip(oldName => oldName.match(/^(.*_V\d+)/)[0] + '_SFX_STEM');
Christian Scheuer @chrscheuer2021-03-13 18:49:29.178Z
So, your entire script would end up like this:
function renameClip(callback) { //Make sure Pro Tools Edit Window is active sf.ui.proTools.appActivateMainWindow(); //Make sure we have no search in Clips list - if we had, Clip Rename won't work (Pro Tools bug) sf.keyboard.press({ keys: 'cmd+shift+d' }); //Clip Clip->Rename... sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] }); //Wait for 'Name' dialog to come up, assign the dialog to dlg variable var dlg = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({}, 'Could not find "Name" dialog').element; //Find the first text field var textField = dlg.groups.whoseTitle.is('Name').first.textFields.first; //Get the current Name var currentName = textField.value.value; //Make a variable with the new name, based on the old one by calling the callback function provided in the 1st argument var newName = callback(currentName); //Set the value of the textField textField.elementSetTextFieldWithAreaValue({ value: newName }); //Press OK dlg.buttons.whoseTitle.is('OK').first.elementClick(); //Wait for the dialog to close dlg.elementWaitFor({ waitForNoElement: true }); } renameClip(oldName => oldName.match(/^(.*_V\d+)/)[0] + '_SFX_STEM');
- DDaniel Lozinski @Daniel_Lozinski
Thanks Christian. So would I create this with script or with the UI functions?
I have no clue when it comes to scripting.
Christian Scheuer @chrscheuer2021-03-13 20:02:49.043Z
Sorry for the confusion. The UI videos I linked to are more for your own long term education :)
You should be able to directly copy/paste the script I made for you and it should just work.
- DDaniel Lozinski @Daniel_Lozinski
This is really great mate. Really appreciate this.
I would love to understand the further mechanics behind why this only names the end of the file after the V1 or V2 etc? It will help me in making further commands.
Christian Scheuer @chrscheuer2021-03-13 20:21:15.763Z
Hi Daniel
This call here:
renameClip(oldName => oldName.match(/^(.*_V\d+)/)[0] + '_SFX_STEM');
has a "callback function", which is this part:
oldName => oldName.match(/^(.*_V\d+)/)[0] + '_SFX_STEM'
That function gets called with the old name (the existing name of the clip), and its role is to then return the new name. The function can either use the existing, old name for something, like just prepending or appending a value, or it can ignore the old name completely. It has full freedom to return whatever new name should be used.
In this case, I'm using a regular expression to find a pattern inside the string:
oldName.match(/^(.*_V\d+)/)
Regular expressions are a huge topic, so not something I can explain here - but search it on Google, you'll find a lot of tutorials.
Basically, what the expression does is finding a pattern from the beginning of the string^
, followed by 0 or more characters (any character).*
then an underscore and a capital V_V
then 1 or more digits\d+
. Finally we take that found pattern as a string by addressing the 0th element of the result[0]
and lastly we append the string'_SFX_STEM'
and return it, so that it becomes the new name.- DDaniel Lozinski @Daniel_Lozinski
Mind blown! haha..
But I get it. I noticed the bit at the end where I have renamed for each clip name I regularly use is at the end.
oldName => oldName.match(/^(.*_V\d+)/)[0] + '_SFX_STEM'
I take it something in the script jumps to the oldName part of the script in order to amend it to the _SFX_STEM part right?
Either way. Thank you. Soundflow is more indepth than I realised and I will remake my buttons using the UI options instead and I can already see that using that will mean I will be able to choose presets and audiosuite more rapidly.
Best,
Daniel
Christian Scheuer @chrscheuer2021-03-13 20:45:23.217Z
I take it something in the script jumps to the oldName part of the script in order to amend it to the _SFX_STEM part right?
If I understand your question correctly: The callback function gets called in this line in the
renameClip
function:var newName = callback(currentName);
Christian Scheuer @chrscheuer2021-03-13 20:45:44.469Z
Either way. Thank you. Soundflow is more indepth than I realised and I will remake my buttons using the UI options instead and I can already see that using that will mean I will be able to choose presets and audiosuite more rapidly.
AWESOME :)
- DDaniel Lozinski @Daniel_Lozinski
Hey Christian,
Just some further help with my re-doing my commands as I want the m to be as efficient as possible.
So I have moved on to my Versioning. I am not sure how to do this with the current method without typing text:
So far I have:
For Copy clip name I have:
Now I would like to then paste - MIX_V1 onto my selected clip.
But I am unsure of how to get the amended text onto that field. I have the first 2 bits. but then it's the adding to the end of the file _MIX_V1 that's the issue without typing right arrow and then typing the text
However, once this is completed. When I do subsequent revisions in the past I just copy the previous mix clip name and then update only the number part because the file name is essentially the same as _MIX_V1.
Make sense?
Thanks,
Daniel
- DDaniel Lozinski @Daniel_Lozinski
okay. I have found a way to do the first one. I found some code you had made for someone else and amended it and it works. not sure if I should have. a wait in any of this for robustness but it seems okay:
function renameClip(callback) {
//Make sure Pro Tools Edit Window is active
sf.ui.proTools.appActivateMainWindow();//Make sure we have no search in Clips list - if we had, Clip Rename won't work (Pro Tools bug) sf.keyboard.press({ keys: 'cmd+shift+d' }); //Clip Clip->Rename... sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] }); sf.ui.proTools.menuClick({
menuPath: ["Edit","Paste"],
});//Wait for 'Name' dialog to come up, assign the dialog to dlg variable var dlg = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({}, 'Could not find "Name" dialog').element; //Find the first text field in the group with title 'Name' var textField = dlg.groups.whoseTitle.is('Name').first.textFields.first; //Get the current Name var currentName = textField.title.value || textField.value.value; //Make a variable with the new name, based on the old one by calling the callback function provided in the 1st argument var newName = callback(currentName); //Set the value of the textField textField.elementSetTextFieldWithAreaValue({ value: newName }); //Press OK dlg.buttons.whoseTitle.is('OK').first.elementClick(); //Wait for the dialog to close dlg.elementWaitFor({ waitForNoElement: true });
}
renameClip(function(oldName) {
//Make the new name the oldName plus ' _MIX_V1'
return oldName + ' _MIX_V1';
});This now does what it needs to. I think what I need now is to amend the other code you wrote for me for the pasting mix names and change it to do the versioning numbers? I will try but correct me if I am wrong.