No internet connection
  1. Home
  2. How to

Wrong tracks being selected while using trackSelectByName() for multilevel nested folders

By Devam @Devam
    2025-05-23 13:06:26.913Z

    I'm building a script to export stems using Stem Bouncing In Pro Tools as a reference, when there's only one level of nesting everything seems to be working fine but when I add one more level of nesting the nested folder seems to get skipped.

    Here's the script to select tracks with names starting with 0 and screenshot attached with what ends up getting selected

    sf.ui.proTools.appActivateMainWindow();
    sf.ui.proTools.mainWindow.invalidate();
    
    let updatedTracks = sf.ui.proTools.trackGetAllTracks();
    let filteredTracks = updatedTracks.names.filter(v => v.startsWith("0"));
    
    sf.ui.proTools.trackSelectByname({names: filteredTracks});
    

    this is what ends up getting selected, while this same script works perfectly fine if I remove the "0 violin stacato" folder. How can I fix this?

    Solved in post #2, click to view
    • 3 replies
    1. Chad Wahlbrink @Chad2025-05-23 14:04:35.559Z

      Hi, @Devam,

      Is your expected result to have "0 strings," "0 violin staccato," and "0 bass" selected in the screenshot above?

      When I set up my session as you have it in that screenshot and run your code, it seems to work as expected.

      You could also try this version which uses the Pro Tools SDK commands for track selection:

      let allTracks = sf.app.proTools.tracks.invalidate().allItems;
      let filteredTracks = allTracks.filter(track => track.name.startsWith('0')).map(track => track.name);
      
      sf.app.proTools.selectTracksByName({ trackNames: filteredTracks, });
      
      ReplySolution
      1. DDevam @Devam
          2025-05-25 15:16:44.267Z

          Hey @Chad, tried this out and it works now! Thanks for the help :)

        • In reply toDevam:
          Chad Wahlbrink @Chad2025-05-23 14:06:33.723Z

          Since you have already started creating this script, it may be best to create a post using the Macro and Script Help workflow.

          This allows other users to see your progress in code form and provide better next steps. This short video explains how to ask for help and upload information in this way:
          https://youtu.be/H3eeKvUIx7g

          Be sure to provide as much information as possible, as the more details you provide, the more efficiently the community can help answer your questions.

          It could also help to provide a quick screen recording of the behavior and send a link via Google Drive or Dropbox.

          Thanks!