Script Sharing - Select Tracks Whose Name Starts with Prefix
By Raphael Sepulveda @raphaelsepulveda2022-04-17 23:44:38.810Z
In this thread, @Thomas_Gloor was asking:
“would you have an idea of a way I could use to select all tracks in the session that start with a particular character? in a CASE SENSITIVE manner?”
This should do the trick!
/** @param {{ prefix: string }} args */
function selectTracksWhoseNameStartsWith({ prefix }) {
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.mainWindow.invalidate();
const allTrackNames = sf.ui.proTools.trackNames;
const tracksWithPrefix = allTrackNames.filter(trackName => trackName.startsWith(prefix));
if (!tracksWithPrefix.length) throw `No tracks with prefix "${prefix}" found.`
sf.ui.proTools.trackSelectByName({ names: tracksWithPrefix, deselectOthers: true });
}
selectTracksWhoseNameStartsWith({
prefix: "GTR" // Enter prefix here
});