No internet connection
  1. Home
  2. How to

Select All Tracks

By Brett Ryan Stewart @Brett_Ryan_Stewart
    2022-01-18 03:48:28.529Z

    Just looking for a simple "select all tracks" command that only selects audio tracks and not aux, master, instrument, etc...

    Solved in post #4, click to view
    • 30 replies

    There are 30 replies. Estimated reading time: 16 minutes

    1. Something ilke this should work:

      
      function isAudioTrack(trackName) {
          var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
          return track.title.value.indexOf('Audio Track') >= 0;
      }
      
      function selectAllAudioTracks() {
          var names = sf.ui.proTools.trackNames.filter(isAudioTrack);
          if (names.length === 0) return;
      
          sf.ui.proTools.trackGetByName({ name: names[0] }).track.trackScrollToView();
          sf.ui.proTools.trackSelectByName({
              names: names,
              deselectOthers: true
          });
      }
      
      selectAllAudioTracks();
      
      1. Thank you! Unfortunately its throwing this error?

        1. samuel henriques @samuel_henriques
            2022-01-18 20:14:26.763Z

            Hello Brett,
            Christian might be busy with the new SF update.

            Try this:

            function isAudioTrack(trackName) {
                var track = sf.ui.proTools.trackGetByName({ name: trackName.normalizedTrackName }).track;
                return track.title.value.indexOf('Audio Track') >= 0;
            }
            
            function selectAllAudioTracks() {
                var names = sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack);
                if (names.length === 0) return;
            
                sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
                sf.ui.proTools.trackSelectByName({
                    names: names.map(t=>t.normalizedTrackName),
                    deselectOthers: true
                });
            }
            
            selectAllAudioTracks();
            
            Reply4 LikesSolution
            1. Oh hell yes, that did it. Thanks Samuel!!

              1. TTristan Hoogland @Tristan
                  2022-10-11 00:00:22.468Z

                  Hi @samuel_henriques

                  I've been utilizing this script in one of my more elaborate scripts - would you happen to have any guidance on selecting all audio tracks, but deselecting/ignoring specific tracks (preferably with the use of wild cards)?

                  My edge case is I'm trying to select all visible audio tracks in my session to print stems, but ignore the last 3 audio tracks in the session. Currently I tag the following on at the end of your script and it works fine, but it re-scans the entire session, which seems a bit redundant - and also I'd just prefer to use wildcards as the track names usually contain specific, yet consistent labeling (i.e. TH MIX, ROUGH MIX)

                  sf.ui.proTools.trackSelectByName({
                      names: sf.ui.proTools.selectedTrackNames.slice(0, -3),
                      deselectOthers: true,
                  });
                  

                  thanks!

                  1. samuel henriques @samuel_henriques
                      2022-10-12 14:10:50.769Z2022-10-13 10:18:55.095Z

                      Hello Tristan,
                      Here's a variation of the same script but now you can choose tracks that are a type AND/OR include in the name some key words.

                      /**
                      * @param {Object} param
                      * @param {'Routing Folder Track'|'Basic Folder Track'|'Audio Track'|'Aux Track'|'VCA Track'|'MIDI Track'|'Inst Track'|'Video Track'|'All Tracks' } [param.trackType]
                      * @param {Array.<string>} [param.includeInName]
                      */
                      function selectTracksByTypeAndIncludesInName({ trackType = "All Tracks", includeInName = [] }) {
                      
                          let type = trackType === "All Tracks" ? "Track" : trackType
                      
                          let names = sf.ui.proTools.invalidate().visibleTrackHeaders.filter(track => {
                      
                              return (track.title.value.trim().endsWith(type)) &&
                                  (includeInName.length >= 1 ? includeInName.some(el => track.normalizedTrackName.indexOf(el) >= 0) : true)
                          });
                      
                          if (names.length === 0) return;
                      
                          sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
                          sf.ui.proTools.trackSelectByName({
                              names: names.map(t => t.normalizedTrackName),
                              deselectOthers: true,
                          });
                      };
                      
                      
                      selectTracksByTypeAndIncludesInName({ trackType: "All Tracks", includeInName: ["TH MIX", "ROUGH MIX", "ANOTHER WORD"] });
                      

                      In this case it will select "All Tracks" where its name includes "TH MIX" OR "ROUGH MIX" OR "ANOTHER WORD".
                      Add here:["TH MIX", "ROUGH MIX", "ANOTHER WORD"] add as many key words as you want.

                      Let me know if this is it

                      1. TTristan Hoogland @Tristan
                          2022-10-12 23:58:03.356Z

                          Thanks for this @samuel_henriques unfortunately I'm not having any luck with it - doesn't seem to do anything actually! ha. Not entirely sure what that could be?

                          1. samuel henriques @samuel_henriques
                              2022-10-13 00:38:54.622Z

                              ahhh.
                              Could you share the complete track names you are trying to select,
                              and what you wrote here includeInName: ["TH MIX", "ROUGH MIX"] ?
                              Just so I test it to see what I missed on the code.

                              1. In reply toTristan:
                                samuel henriques @samuel_henriques
                                  2022-10-13 09:31:09.382Z

                                  Just updated the script with better features and usage.
                                  But couldn't find anything wrong with the previous one.

                                  1. TTristan Hoogland @Tristan
                                      2022-10-13 15:42:04.912Z

                                      Hi Sam! Ahh I think this is working as you intended (which is actually very useful within itself!). What I was hoping was the complete inverse of what you've created here - I want to select all tracks, but then exclude specific tracks. Does that make sense?

                                      1. samuel henriques @samuel_henriques
                                          2022-10-13 15:50:49.768Z2022-10-13 15:59:13.020Z

                                          Woops! That's right, that's what the code you were using does. Let me think of a cool and fast way to go about this. When selecting all tracks using the all group click, the way Matt Friedman shared, it opens all the folder tracks, is that ok for you?

                                          1. TTristan Hoogland @Tristan
                                              2022-10-13 15:53:50.911Z

                                              ha - all good! I'm sure it's going to come in handy too.

                                              That's fine by me! (Maybe even preferred). Plus I barely use folder tracks anyway.

                                              1. samuel henriques @samuel_henriques
                                                  2022-10-13 18:34:12.827Z

                                                  Could you confirm the tracks you want unselected are always next to each other and all visible on the same screen ?
                                                  Two track together wouldn't be a problem, but if you think there is a chance they could be 20, I could have to change my idea.

                                                  1. In reply toTristan:
                                                    samuel henriques @samuel_henriques
                                                      2022-10-13 18:57:32.366Z

                                                      Presuming the last question is true, here's something.
                                                      Easiest and safest than this would be to create a group excluding these tracks and the script would just click that group symbol.

                                                      /**
                                                      * @param {string} name
                                                      */
                                                      function selectAllTracksFromGroupSymbol(name = "<ALL>") {
                                                      
                                                          sf.ui.proTools.groupsEnsureGroupListIsVisible();
                                                      
                                                          // Get all groups info
                                                          const groupListState = sf.ui.proTools.mainWindow.groupListView.invalidate().childrenByRole('AXRow').map(r => ({
                                                              groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1],
                                                              groupSymbol: r.childrenByRole('AXCell').allItems[0].buttons.first,
                                                              groupState: r.childrenByRole('AXCell').allItems[0].buttons.first.value.invalidate().value.replace("Selected. , ", ""),
                                                              groupIsSelected: r.childrenByRole('AXCell').allItems[0].buttons.first.value.invalidate().value.startsWith("Selected.")
                                                          }));
                                                      
                                                          groupListState.filter(grp => grp.groupName === name)[0].groupSymbol.elementClick();
                                                      };
                                                      
                                                      
                                                      
                                                      /**
                                                      * @param {Array.<string>} unselectOptions
                                                      */
                                                      function selectAllTracksANDunselectTracksWith(unselectOptions) {
                                                      
                                                          const unselectTracks = sf.ui.proTools.visibleTrackHeaders.filter(track =>
                                                              unselectOptions.some(el => track.normalizedTrackName.includes(el))
                                                          );
                                                      
                                                      
                                                          unselectTracks[0].trackSelect();
                                                          unselectTracks[0].trackScrollToView();
                                                          unselectTracks[0].popupButtons.first.mouseClickElement({ isShift: true, isControl: true });
                                                      
                                                          //No parameter will use by default group <ALL>
                                                          selectAllTracksFromGroupSymbol();
                                                      
                                                      
                                                          unselectTracks.forEach(tr => tr.popupButtons.first.mouseClickElement({ isCommand: true }));
                                                      };
                                                      
                                                      // Exclude from selection tracks that include these strings
                                                      selectAllTracksANDunselectTracksWith(["ROUGH MIX", "TH MIX"]);
                                                      
                                                      
                                                      
                                                      1. TTristan Hoogland @Tristan
                                                          2022-10-14 03:57:24.465Z

                                                          Hey sam! This is cool, soooo close. The only issue is that it's also selecting all auxiliaries. The earlier script which focuses on the audio tracks still works best. I was wondering if there was also a way to make sure it ignores inactive tracks? I might try my hand at it in the next few days, just been bogged down in other scripts - ha!

                                                          Thanks so much man. SO close.

                                                          1. samuel henriques @samuel_henriques
                                                              2022-10-14 11:33:46.129Z

                                                              Continuation here:
                                                              Select tracks by

                                            • Andrew Piland @Andrew_Piland
                                                2024-02-08 15:58:36.572Z

                                                Hi Samuel,

                                                I'm trying to alter this script to do Instrument Tracks instead and not having any luck.

                                                1. samuel henriques @samuel_henriques
                                                    2024-02-08 16:18:02.492Z

                                                    Hello Andrew,
                                                    If you are trying to select tracks by type, use this
                                                    Select All Tracks #post-12

                                                    1. Andrew Piland @Andrew_Piland
                                                        2024-02-08 16:21:54.909Z

                                                        Ah thank you so much! That post was super helpful

                                              • M
                                                Matt Friedman @Matt_Friedman
                                                  2022-02-11 20:19:44.523Z

                                                  Just because the title of this is Select All Tracks, I came up with this simple one.

                                                  I tried working with the script above but it seemed to have trouble on really big sessions with lots and lots of tracks with the error:
                                                  Could not restore selection of the right track (Select All Tracks: Line 11)

                                                  So this script just clicks next to the ALL group to select all tracks.

                                                  sf.ui.proTools.mainWindow.tables.whoseTitle.is("Group List").first.children.whoseRole.is("AXColumn").whoseTitle.is("State ").first.children.whoseRole.is("AXRow").whoseValue.is("").first.children.whoseRole.is("AXCell").first.buttons.first.elementClick();
                                                  
                                                  1. Very nice ,thanks Matt!

                                                  2. G
                                                    Glen Schaele @Glen_Schaele
                                                      2022-10-11 08:48:00.852Z

                                                      that's pretty cool!
                                                      How does it work when i ionly want to "select all basic routing folders? "
                                                      Cant find proper commands for that.

                                                      Thank you! :)

                                                      1. samuel henriques @samuel_henriques
                                                          2022-10-11 09:59:20.071Z

                                                          I'm out of the office and can't test now.
                                                          But on my version of the code, on line 3 where it say 'Audio Track' replace with 'Routing Folder Track'. 'Folder Track' should select all folders.
                                                          Tomorrow I should be able to test it out, if it's not working for you.

                                                          1. GGlen Schaele @Glen_Schaele
                                                              2022-10-11 10:22:00.877Z

                                                              Hey buddy, thanks for the quick response!

                                                              Right, so ATM i have this:

                                                              preformatted text
                                                              ```function isAudioTrack(trackName) {
                                                                  var track = sf.ui.proTools.trackGetByName({ name: trackName.normalizedTrackName }).track;
                                                                  return track.title.value.indexOf('Routing Folder Track') >= 0;
                                                              }
                                                              
                                                              function selectAllAudioTracks() {
                                                                  var names = sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack);
                                                                  if (names.length === 0) return;
                                                              
                                                                  sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
                                                                  sf.ui.proTools.trackSelectByName({
                                                                      names: names.map(t=>t.normalizedTrackName),
                                                                      deselectOthers: true
                                                                  });
                                                              }
                                                              
                                                              selectAllAudioTracks();
                                                              
                                                              
                                                              
                                                              not working yet. Would love to hear back from you when you can. 
                                                              Cheers!
                                                              1. samuel henriques @samuel_henriques
                                                                  2022-10-12 10:43:57.657Z

                                                                  Hello Glen,
                                                                  This should work,

                                                                  /**
                                                                  * @param{{trackType: 'Routing Folder Track'|'Basic Folder Track'|'Audio Track'|'Aux Track'|'VCA Track'|'MIDI Track'|'Inst Track'|'Video Track'}} trackType
                                                                  */
                                                                  function selectTracksByType({ trackType }) {
                                                                  
                                                                      const names = sf.ui.proTools.visibleTrackHeaders.filter(track => {
                                                                          return track.title.value.trim().endsWith(trackType)
                                                                      });
                                                                  
                                                                      if (names.length === 0) return;
                                                                  
                                                                      sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
                                                                      sf.ui.proTools.trackSelectByName({
                                                                          names: names.map(t => t.normalizedTrackName),
                                                                          deselectOthers: true,
                                                                      });
                                                                  }
                                                                  
                                                                  selectTracksByType({ trackType: "Basic Folder Track" });
                                                                  

                                                                  If you type F2 between the quotes you'll get a list of all the track types

                                                                  1. Excellent code, Samuel!

                                                                    1. samuel henriques @samuel_henriques
                                                                        2022-10-12 11:23:56.733Z

                                                                        Thank you so much Christian, I'm just adding to your code :)

                                                              2. G
                                                                Glen Schaele @Glen_Schaele
                                                                  2022-10-16 09:59:06.092Z

                                                                  This really helped! Thank you very much!

                                                                  1. Brenden @nednednerb
                                                                      2022-10-16 21:46:27.059Z

                                                                      Hi there,

                                                                      I used the script by Samuel, (didn't try previous ones).

                                                                      I duplicated the script and made 4 to select different types of tracks. I made 4 keyboard shortcuts.
                                                                      I then duplicated that set, to make versions with "deselectOthers: false," in order to use another 4 shortcuts which would include more kinds of tracks. That way I could use two shortcuts to quickly select Audio and Aux for example. Or two shortcuts to select Audio OR Aux (which the above script did perfectly).

                                                                      How is the deselectOthers supposed to work? I think I saw no mention of this above, has this part been varied and tested by anyone?