No internet connection
  1. Home
  2. Script Sharing

Script Sharing - Select Tracks Whose Name Starts with Prefix

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
});
  • 1 replies
  1. T
    Thomas Gloor @Thomas_Gloor
      2022-04-18 14:34:16.243Z

      Hey @raphaelsepulveda

      You're the absolute best! Thank you so much!