Trying to move bounce files from Clip List. Running into errors.
All,
I have a workflow in mind where after I print my stems for each spot, I grab the clips and move them to the tracks that they need to live on. The good news is that all of these are being done from a set template, so I know what the backend of each printed track will be named as well as the names of the destination tracks.
Pro Tools doesn't bring the bounces back in the same order that I had them setup in the bounce window, otherwise this would be much simpler.
function selectTracksByNameWithWildcard(trackNames = []) {
function matchWildcard(str, rule) {
var escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$", "i").test(str);
}
var allNames = sf.ui.proTools.trackNames;
var namesToSelect = allNames.filter(n => trackNames.some(tn => matchWildcard(n, tn)));
sf.ui.proTools.trackSelectByName({
names: namesToSelect,
deselectOthers: true,
});
}
const suffixFiveOnePm = ("_" + "01 Print Master Record Bus");
const suffixTwoOhPm = ("_" + "02 Stereo Print Master");
const suffixTwoOhMne = ("_" + "03 Stereo ME Record Bus");
const suffixMonoVoDx = ("_" + "04 Mono VO_DX Record Bus");
const suffixMonoMne = ("_" + "05 Mono ME Record Bus");
const suffixGenMonoVo = ("_" + "06 Mono VO Record Bus");
const suffixGenMonoDx = ("_" + "07 Mono DX Record Bus");
const suffixGenStereoFx = ("_" + "08 Stereo SFX Record Bus");
const suffixGenStereoMx = ("_" + "09 Stereo Music Record Bus");
const tracksFiveOnePm = ("Sub 5.1 - L" + "," + "Sub 5.1 - C" + "," + "Sub 5.1 - R" + "," + "Sub 5.1 - Ls" + "," + "Sub 5.1 - Rs" + "," + "Sub 5.1 - Lfe");
const tracks20Pm = ("Sub 2.0 MnE - L" + "," + "Sub 2.0 MnE - R");
const tracks20Mne = ("Sub 2.0 MnE - L" + "," + "Sub 2.0 MnE - R");
const tracks10VoDx = ("Sub 1.0 VO DX");
const tracks10MnE = ("Sub 1.0 MnE");
const tracksGen1 = ("Sub 1.0 VO DX");
const tracksGen2 = ("Gen 1.0 Dx");
const tracksGen3 = ("Gen 2.0 FX - L" + "," + "Gen 2.0 FX - R");
const tracksGen4 = ("Gen 2.0 MX - L" + "," + "Gen 2.0 MX - R");
selectTracksByNameWithWildcard([
'*01 Print Master*',
]);
sf.ui.proTools.appActivateMainWindow();
sf.wait();
//goto start of session
sf.keyboard.press({
keys: "numpad multiply, numpad clear, numpad 5, numpad 9, numpad 5, numpad 0, numpad 0, numpad 0, numpad enter",
});
//select clip
sf.keyboard.press({
keys: "ctrl+tab",
});
//rename clip window
sf.ui.proTools.menuClick({
menuPath: ["Clip", "Rename..."],
});
//get clip name without extention
var parentName = sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.children.whoseRole.is("AXStaticText").allItems[2].value.value;
let parentNameBase = parentName.split('_')[0];
//close rename window
sf.ui.proTools.windows.whoseTitle.is('Name').first.buttons.whoseTitle.is('Cancel').first.elementClick();
function getClips(suffix, tracks) {
//alert(suffix);
//alert(tracks);
suffixString = suffix.toString();
trackString = tracks.toString();
sf.keyboard.press
({
keys: "cmd+shift+f",
});
sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.elementWaitFor();
sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.textFields.whoseTitle.is('').first.elementSetTextAreaValue({
value: parentNameBase + suffixString
});
sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.buttons.whoseTitle.is('OK').first.elementClick();
sf.keyboard.press({
keys: "cmd+c",
});
sf.ui.proTools.trackSelectByName({
names: trackString,
deselectOthers: true
});
sf.keyboard.press({
keys: "cmd+v",
});
}
getClips(suffixFiveOnePm, tracksFiveOnePm);
//getClips(suffixTwoOhPm, tracks20Pm);
//getClips(suffixTwoOhMne, tracks20Mne);
//getClips(suffixMonoVoDx, tracks10VoDx);
//getClips(suffixMonoMne, tracks10MnE);
//getClips(suffixGenMonoVo, tracksGen1);
//getClips(suffixGenMonoDx, tracksGen2);
//getClips(suffixGenStereoFx, tracksGen3);
//getClips(suffixGenStereoMx, tracksGen4);
I am "borrowing" code from a different post here to enable the select by wildcard.
I am getting s "String Array expect for 'names'." error. When I had the alerts active, it looked like I was sending the correct thing, but I am obviously not.
What am I doing wrong? Is there an easier/better way to do this?
Thanks,
Randall
- Christian Scheuer @chrscheuer2021-02-12 09:47:47.612Z
Hi Randall,
This code:
sf.ui.proTools.trackSelectByName({ names: trackString, deselectOthers: true });
should be:
sf.ui.proTools.trackSelectByName({ names: [trackString], deselectOthers: true });
Christian Scheuer @chrscheuer2021-02-12 09:51:11.461Z
There's a lot of potential for optimization.
I'd recommend using some existing functions for getting clip names, to simplify your code - for example the function
getClipName
from this post:To set the selection, instead of using keyboard simulation, do this (if in timecode):
sf.ui.proTools.selectionSet({ selectionStart: '59:50:00:00', selectionEnd: '59:50:00:00', });
Christian Scheuer @chrscheuer2021-02-12 09:52:21.065Z
I'd also recommend using menu items "Edit->Copy" etc. instead of "cmd+c" and "cmd+v" whenever you can, as it's more stable.
- In reply tochrscheuer⬆:RRandall Smith @Randall_Smith
Thank you for helping me out Christian...as you know I am not a programmer.
I still get the same 'expected string' error on the sf.ui.proTools.trackSelectByName. As such, the script keeps failing out there.
Also, I tried a different approach where I used the SpotFromClipList command, but the spot location was off by a few seconds. I am assuming that is not expected behaviour and that I didn't do something to make it work correctly. (Expected to spot to 59:50:00 and got the clip spotted at 59:54:00(or there abouts).
Thanks,
Randall SmithChristian Scheuer @chrscheuer2021-02-17 14:20:39.183Z
Hi Randall,
In that case, please share the entire script you're using with my change. If you still get the same error, it sounds like you didn't apply my changes correctly.
- RRandall Smith @Randall_Smith
function selectTracksByNameWithWildcard(trackNames = []) { function matchWildcard(str, rule) { var escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$", "i").test(str); } var allNames = sf.ui.proTools.trackNames; var namesToSelect = allNames.filter(n => trackNames.some(tn => matchWildcard(n, tn))); sf.ui.proTools.trackSelectByName({ names: namesToSelect, deselectOthers: true, }); } const suffixFiveOnePm = ("_" + "01 Print Master Record Bus"); const suffixTwoOhPm = ("_" + "02 Stereo Print Master"); const suffixTwoOhMne = ("_" + "03 Stereo ME Record Bus"); const suffixMonoVoDx = ("_" + "04 Mono VO_DX Record Bus"); const suffixMonoMne = ("_" + "05 Mono ME Record Bus"); const suffixGenMonoVo = ("_" + "06 Mono VO Record Bus"); const suffixGenMonoDx = ("_" + "07 Mono DX Record Bus"); const suffixGenStereoFx = ("_" + "08 Stereo SFX Record Bus"); const suffixGenStereoMx = ("_" + "09 Stereo Music Record Bus"); const tracksFiveOnePm = ("Sub 5.1 - L" + "," + "Sub 5.1 - C" + "," + "Sub 5.1 - R" + "," + "Sub 5.1 - Ls" + "," + "Sub 5.1 - Rs" + "," + "Sub 5.1 - Lfe"); const tracks20Pm = ("Sub 2.0 MnE - L" + "," + "Sub 2.0 MnE - R"); const tracks20Mne = ("Sub 2.0 MnE - L" + "," + "Sub 2.0 MnE - R"); const tracks10VoDx = ("Sub 1.0 VO DX"); const tracks10MnE = ("Sub 1.0 MnE"); const tracksGen1 = ("Sub 1.0 VO DX"); const tracksGen2 = ("Gen 1.0 Dx"); const tracksGen3 = ("Gen 2.0 FX - L" + "," + "Gen 2.0 FX - R"); const tracksGen4 = ("Gen 2.0 MX - L" + "," + "Gen 2.0 MX - R"); selectTracksByNameWithWildcard([ '*01 Print Master*', ]); sf.ui.proTools.appActivateMainWindow(); sf.wait(); sf.ui.proTools.selectionSet({ selectionStart: '00:59:50:00', selectionEnd: '00:59:50:00', }); //select clip sf.keyboard.press({ keys: "ctrl+tab", }); //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 clipName = textField.value.value; //Close Window dlg.buttons.whoseTitle.is('Cancel').first.elementClick(); //Wait for the dialog to close dlg.elementWaitFor({ waitForNoElement: true }); //get clip name without extention //var clipName = sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.children.whoseRole.is("AXStaticText").allItems[2].value.value; let parentNameBase = clipName.split('_')[0]; alert (parentNameBase); function getClips(suffix, tracks) { alert(suffix); alert(tracks); var suffixString = suffix.toString(); var trackString = tracks.toString(); var nameWithSuffix = (""+parentNameBase+suffix); alert (nameWithSuffix); sf.keyboard.press ({ keys: "cmd+shift+f", }); sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.elementWaitFor(); sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.textFields.whoseTitle.is('').first.elementSetTextAreaValue({ value: parentNameBase, }); sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.buttons.whoseTitle.is('OK').first.elementClick(); sf.ui.proTools.menuClick({ menuPath: ["Edit", "Copy"], }); sf.ui.proTools.trackSelectByName({ names: [trackString], deselectOthers: true }); sf.ui.proTools.menuClick({ menuPath: ["Edit", "Paste"], }); } getClips(suffixFiveOnePm, tracksFiveOnePm); //getClips(suffixTwoOhPm, tracks20Pm); //getClips(suffixTwoOhMne, tracks20Mne); //getClips(suffixMonoVoDx, tracks10VoDx); //getClips(suffixMonoMne, tracks10MnE); //getClips(suffixGenMonoVo, tracksGen1); //getClips(suffixGenMonoDx, tracksGen2); //getClips(suffixGenStereoFx, tracksGen3); //getClips(suffixGenStereoMx, tracksGen4);
Here is the updated script. I replaced the Get Clips function with what you suggested and replaced the key stroke commands with menu UI.
It seems to stall out here
sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.textFields.whoseTitle.is('').first.elementSetTextAreaValue({ value: parentNameBase, });
It is not inputing the variable name into the find box correctly.
Christian Scheuer @chrscheuer2021-02-18 10:36:26.075Z
That's great progress!
I think you may need to use
elementSetTextFieldWithAreaValue
instead ofelementSetTextAreaValue
:)