Hi! I have a script that I have made through compiling forum scripts and from @Kitch 's great lesson on taking text from UI items.
It does what I want to, except that I would like the script to take the clip name (as it does) and then removing a few lines of text before its pasting the name in the Bounce Mix Window. The Script goes as following:
sf.ui.proTools.menuClick({
menuPath: ["View","Other Displays","Clip List"],
targetValue: "Enable",
});
function getSelectedClipNamesFromClipList() {
const clipsTable = sf.ui.proTools.mainWindow.tables.whoseTitle.is('CLIPS').first;
// Get all selected clips
const selectedClips = clipsTable.children.whoseRole.is("AXRow").allItems.map(row =>
row.children[1].children.first.value.value).filter(c => c.startsWith('Selected. '));
// Extract clip names
const clipNames = selectedClips.map(c => c.split('"')[1]);
return clipNames
};
const selectedClip = getSelectedClipNamesFromClipList()[0];
sf.ui.proTools.selectedTrack.trackSetSolo({
targetValue: "Enable",
});
sf.ui.proTools.selectedTrack.trackSetMute({
targetValue: "Disable",
});
sf.ui.proTools.selectedTrack.trackOutputSelect({
outputPath: ["bus","bus menu 1-128","∑ TRANSPORT (Stereo)"],
});
sf.ui.proTools.menuClick({
menuPath: ["File","Bounce Mix..."],
});
sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.elementWaitFor();
sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.textFields.first.elementSetTextFieldWithAreaValue({value:selectedClip});
The clips are always namned something like: SongName_ArtistName_Mix_V.1_6_Binaural.BIN
I would like the script to remove the text "_Binaural.BIN" and the _number (which can be two numbers, like 11 or so, depending of the project version) so that the file name returns SongName_ArtistName_Mix_V.1.
I know this is a very Java Script basic question, but I hope its not too out of the way for this forum!
Thank you so much!!
All the best,
Gabriel
- samuel henriques @samuel_henriques
Hey @Gabriel_Lundh,
Try replacing this line:
const selectedClip = getSelectedClipNamesFromClipList()[0];
With:
const selectedClip = getSelectedClipNamesFromClipList()[0].split("_").slice(0,-2).join("_");
hope it helps!!
- GIn reply toGabriel_Lundh⬆:Gabriel Lundh @Gabriel_Lundh
@samuel_henriques, Thank you so much! This works like a charm! I will try to finally understand the split, slice and join terms from now on.
Thanks for helping out!
- Christian Scheuer @chrscheuer2021-02-02 21:05:23.147Z
Hi Gabriel,
Here you can see what split, slice and join does on a sample string:
split('_')
will split the string into an array of strings, separated by each '_' character.slice(0, -2)
will take all elements of the array and make a new array, except the last two items (-2
)join('_')
will take the array elements and join them together as one single string, joining with the '_' character.
- GGabriel Lundh @Gabriel_Lundh
Thank you so much Christian!! Such a great explenation! This will certainly be used in the future!
Love the community you've created!
All the best,
Gabriel
- Progress