No internet connection
  1. Home
  2. How to

Select Track Based on Partial Name of Insert

By Philip weinrobe @Philip_weinrobe
    2022-08-19 18:17:01.326Z

    Hi Geniuses at Soundflow!
    I am trying to select all tracks that have a hardware insert on them. I bought Scheps Track Selector ($39) but it's crashing very quickly and I think it may be a bit overbuilt for my limited needs.

    I am happy to make a naming convention on all my hardware inserts (for example "hw"). I would then like to have a script that selected all tracks that had an insert with "hw" in the name. i'd like to limit this to visible tracks (no searching my hidden tracks!).

    is this possible? I can't seem to figure it out. @Andrew_Scheps seemed to indicate in another thread that this is possible, but i'm just not sure how to do it.

    thank you so much!
    philip

    • 29 replies

    There are 29 replies. Estimated reading time: 17 minutes

    1. In reply toPhilip_weinrobe:
      Chris Shaw @Chris_Shaw2022-08-19 20:59:59.252Z2022-08-19 21:54:33.169Z

      try this:

      sf.ui.proTools.appActivateMainWindow();
      sf.ui.proTools.mainWindow.invalidate();
      
      // Ensure Inserts are visible
      const AEInsertsMenuPath = ['View', 'Edit Window Views', 'Inserts A-E']
      const FJInsertsMenuPath = ['View', 'Edit Window Views', 'Inserts F-J']
      
      const insertsAEShowing = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts A-E').isMenuChecked;
      const insertsFJShowing = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts F-J').isMenuChecked;
      
      if (!insertsAEShowing) sf.ui.proTools.menuClick({ menuPath: AEInsertsMenuPath, targetValue: "Enable" });
      if (!insertsFJShowing) sf.ui.proTools.menuClick({ menuPath: FJInsertsMenuPath, targetValue: "Enable" });
      
      // Get visible track headers
      const visibleTracks = sf.ui.proTools.visibleTrackHeaders;
      
      //filter out tracks that are VCA and Basic Folder
      const tracksWithInserts = visibleTracks.filter(t => !t.title.value.includes("Basic Folder Track"))
          .filter(tr => !tr.title.value.includes("VCA Track"))
          .map(i => i.normalizedTrackName);
      
      //Declare tracks with hw inserts variable
      var tracksWithHWInserts = [];
      
      //Loop through tracks with inserts, look at each insert name and find track whose insert names contain "hw"
      // if found, add to tracksWInserts array
      tracksWithInserts.forEach(track => {
          sf.ui.proTools.trackSelectByName({ names: [track] })
          for (var i = 0; i < 10; i++) {
              var insertName = sf.ui.proTools.selectedTrack.insertButtons[i].value.invalidate().value;
              if (insertName.includes("hw")) { tracksWithHWInserts.push(track) }
          }
      })
      
      // select tracks with hw inserts
      sf.ui.proTools.trackSelectByName({ names: tracksWithHWInserts })
      
      // Restore Inserts Views
      if (!insertsAEShowing) sf.ui.proTools.menuClick({ menuPath: AEInsertsMenuPath, targetValue: "Disable" });
      if (!insertsFJShowing) sf.ui.proTools.menuClick({ menuPath: FJInsertsMenuPath, targetValue: "Disable" });
      
      log ("Find tracks w/ hardware inserts",`${tracksWithHWInserts.length} tracks with hardware inserts were found`)
      
      1. oops! there was an error.
        The above code has been edited.

        1. PPhilip weinrobe @Philip_weinrobe
            2022-08-19 22:37:37.222Z

            ok this works great EXCEPT it fails if it comes across a folder nested more than 1 folder down in a set. so if i have a folder, inside a folder, inside a folder...that is where the script fails. any way to make it not fail there?

            it weirdly opens up the track color menu then kiels over and dies lol.

            it says "no track selected in track view" when this happens

            1. PPhilip weinrobe @Philip_weinrobe
                2022-08-19 22:38:08.530Z

                if i close that 2nd gen nested folder, the scripts works perfect

                1. Unfortunately I don't have the time to write the routine that opens all folders before hand.

                  I suggest you use use @samuel_henriques 's open all folders script first. Then run the above script.

                  1. PPhilip weinrobe @Philip_weinrobe
                      2022-08-21 16:01:53.304Z

                      Hi Chris
                      Actually, all the folders are already open. I can do that manually. The problem is that the script hangs when it encounters a folder that is 2 "generations" in.

                      What do you think?
                      Philip

                      1. PPhilip weinrobe @Philip_weinrobe
                          2022-08-22 13:21:13.254Z

                          @samuel_henriques
                          any chance you could help with this? it's so close!

                          thank you everyone!

                          it's almost perfect...i make sure that all folders are open. however, the script fails if a folder is 2 generations in...

                          thank you all so much!
                          philip

                          1. TThomas Gloor @Thomas_Gloor
                              2022-08-22 13:40:18.677Z

                              @Philip_weinrobe

                              Hey Philip! What are you looking to do? I've been fiddling with some hardware insert scripts. Maybe I can help?

                              1. In reply toPhilip_weinrobe:
                                samuel henriques @samuel_henriques
                                  2022-08-22 14:19:56.482Z

                                  Just updated my latest open/close all folders.
                                  Try it, maybe it'll help.
                                  Is there a script to un-fold and fold folder tracks? #post-39

                                  are you using Chris Shaw script after my script to open all folders?

                                  1. PPhilip weinrobe @Philip_weinrobe
                                      2022-08-22 14:44:48.141Z

                                      Hi Samuel
                                      Yes, I am using the Chris Shaw script after opening all the folders. The issue with the Chris Shaw script is that it hangs when it encounters an OPEN folder with tracks in it in which the open folder is 2 generations or more down the folder tree. Does that make sense?

                                      Philip

                                      1. PPhilip weinrobe @Philip_weinrobe
                                          2022-08-22 14:45:16.426Z

                                          oh, for the Chris Shaw script to find the HW inserts, all folders must be open. that's not a problem and we love it!

                                          1. samuel henriques @samuel_henriques
                                              2022-08-22 14:50:02.987Z

                                              is it failing and saying track doesn't have element or similar?
                                              is it on the loop?

                                              1. PPhilip weinrobe @Philip_weinrobe
                                                  2022-08-22 14:52:49.828Z

                                                  yes, that's exactly what is happening. it's also, strangely, opening the color pallette when this happens lol

                                                  1. samuel henriques @samuel_henriques
                                                      2022-08-22 15:30:20.837Z2022-08-22 17:27:52.130Z

                                                      Do you have video tracks on your session?

                                                      1. samuel henriques @samuel_henriques
                                                          2022-08-22 15:32:15.339Z

                                                          I made a tiny tweak on @Chris_Shaw's script ( Chris I hope you don't mind).
                                                          Try this instead:

                                                          
                                                          sf.ui.proTools.appActivateMainWindow();
                                                          sf.ui.proTools.mainWindow.invalidate();
                                                          sf.ui.proTools.trackDeselectAll();
                                                          
                                                          // Ensure Inserts are visible
                                                          const AEInsertsMenuPath = ['View', 'Edit Window Views', 'Inserts A-E']
                                                          const FJInsertsMenuPath = ['View', 'Edit Window Views', 'Inserts F-J']
                                                          
                                                          const insertsAEShowing = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts A-E').isMenuChecked;
                                                          const insertsFJShowing = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts F-J').isMenuChecked;
                                                          
                                                          if (!insertsAEShowing) sf.ui.proTools.menuClick({ menuPath: AEInsertsMenuPath, targetValue: "Enable" });
                                                          if (!insertsFJShowing) sf.ui.proTools.menuClick({ menuPath: FJInsertsMenuPath, targetValue: "Enable" });
                                                          
                                                          // Get visible track headers
                                                          const visibleTracks = sf.ui.proTools.visibleTrackHeaders;
                                                          
                                                          //filter out tracks that are VCA and Basic Folder
                                                          const tracksWithInserts = visibleTracks.filter(tr =>
                                                              !tr.title.value.includes("Basic Folder Track") &&
                                                              !tr.title.value.includes("VCA Track") &&
                                                              !tr.title.value.includes("Video Track")
                                                          );
                                                          
                                                          //Declare tracks with hw inserts variable
                                                          var tracksWithHWInserts = [];
                                                          
                                                          //Loop through tracks with inserts, look at each insert name and find track whose insert names contain "hw"
                                                          // if found, add to tracksWInserts array
                                                          tracksWithInserts.forEach(track => {
                                                              // sf.ui.proTools.trackSelectByName({ names: [track] })
                                                              for (var i = 0; i < 10; i++) {
                                                                  var insertName = track.insertButtons[i].value.invalidate().value;
                                                                  if (insertName.includes("hw")) { tracksWithHWInserts.push(track) };
                                                              };
                                                          });
                                                          
                                                          // select tracks with hw inserts
                                                          sf.ui.proTools.trackSelectByName({ names: tracksWithHWInserts.map(th => th.normalizedTrackName) });
                                                          
                                                          
                                                          
                                                          // Restore Inserts Views
                                                          if (!insertsAEShowing) sf.ui.proTools.menuClick({ menuPath: AEInsertsMenuPath, targetValue: "Disable" });
                                                          if (!insertsFJShowing) sf.ui.proTools.menuClick({ menuPath: FJInsertsMenuPath, targetValue: "Disable" });
                                                          
                                                          log("Find tracks w/ hardware inserts", `${tracksWithHWInserts.length} tracks with hardware inserts were found`)
                                                          
                                                          1. samuel henriques @samuel_henriques
                                                              2022-08-22 15:36:32.458Z

                                                              Just changed a mistake.
                                                              It might be a bug, in this case if there is any selected track, it wont select the found track.

                                                            • PPhilip weinrobe @Philip_weinrobe
                                                                2022-08-22 15:38:13.119Z

                                                                no video tracks :)

                                                                1. PPhilip weinrobe @Philip_weinrobe
                                                                    2022-08-22 18:08:43.604Z

                                                                    hi @samuel_henriques
                                                                    that new code you updated won't run at all. fails as soon as I try

                                                                    1. PPhilip weinrobe @Philip_weinrobe
                                                                        2022-08-22 18:09:44.863Z

                                                                        oops. i take it back...may work perfect!

                                                                        1. PPhilip weinrobe @Philip_weinrobe
                                                                            2022-08-22 18:12:28.416Z

                                                                            ok it works PERFECT
                                                                            only weird thing is that it opens the color pallete dialog at the end and i can't figure out why...it's not open in the beginning when i run the script....

                                                                            1. samuel henriques @samuel_henriques
                                                                                2022-08-22 18:14:30.223Z

                                                                                awesome.
                                                                                it opens the color palette with my open/close folder tracks script?

                                                                                1. PPhilip weinrobe @Philip_weinrobe
                                                                                    2022-08-23 15:16:12.375Z

                                                                                    hi samuel
                                                                                    i actually am not using your open/close script. i make sure the folders are open manually.
                                                                                    at the end of the Chris Shaw script exactly as you posted it (with the fix) it opens the color pallette window.
                                                                                    weird, right?

                                                                                    1. samuel henriques @samuel_henriques
                                                                                        2022-08-23 17:21:56.109Z

                                                                                        In the past, I've had similar weird behaviour with the colour palette, but couldn't figure it out, restarting pro tools (not just close and open session) fixed it for me.
                                                                                        I've been trying now different ways to reproduce the error you are getting, but no luck so far.

                                                                                        1. TTristan Hoogland @Tristan
                                                                                            2022-11-15 00:19:21.824Z

                                                                                            hey guys!

                                                                                            Just chiming in to say this is amazing (though I'm using it to search for other plugins).

                                                                                            I had a quick question - is there a way to ignore:
                                                                                            Tracks that contain said inserts, but are inactive
                                                                                            Tracks that contain said inserts, but the insert itself is inactive

                                                                                            Thanks!

                                                                                            1. PPhilip weinrobe @Philip_weinrobe
                                                                                                2022-11-15 00:29:10.771Z

                                                                                                funny, i deal with this problem all the time and would LOVE a solution for it.
                                                                                                tbh, it forces me to clean up my sessions when i need to do this search. so i'm kinda using it to do some tidying (bye bye to inactive tracks and getting rid of inactive plugins)

                                                                                                but, in reality, it would just be nicer if it only grabbed Active Tracks AND Active Inserts.

                                                                                                1. PPhilip weinrobe @Philip_weinrobe
                                                                                                    2024-03-21 13:42:45.815Z

                                                                                                    hi @samuel_henriques
                                                                                                    i finally updated pro tools today to 2024.3 today and soundflow to 5.7.5 and now everything is breaking and i'm combing through to fix.

                                                                                                    this script here is now broken and would love some help figuring out how to fix it

                                                                                                    
                                                                                                    function main() {
                                                                                                        sf.ui.proTools.appActivateMainWindow();
                                                                                                        sf.ui.proTools.mainWindow.invalidate();
                                                                                                    
                                                                                                        const aEInsertMenuPath = ['View', 'Edit Window Views', 'Inserts A-E'];
                                                                                                        const fJInsertMenuPath = ['View', 'Edit Window Views', 'Inserts F-J'];
                                                                                                    
                                                                                                        const insertsAEShowing = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts A-E');
                                                                                                        const insertsFJShowing = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts F-J');
                                                                                                    
                                                                                                        if (!insertsAEShowing.isMenuChecked) {
                                                                                                            sf.ui.proTools.menuClick({
                                                                                                                menuPath: aEInsertMenuPath,
                                                                                                                targetValue: "Enable"
                                                                                                            });
                                                                                                        }
                                                                                                    
                                                                                                        if (!insertsFJShowing.isMenuChecked) {
                                                                                                            sf.ui.proTools.menuClick({
                                                                                                                menuPath: fJInsertMenuPath,
                                                                                                                targetValue: "Enable"
                                                                                                            });
                                                                                                        }
                                                                                                    
                                                                                                        let visibleTracks = sf.ui.proTools.invalidate().visibleTrackHeaders;
                                                                                                    
                                                                                                        // Filters Tracks without Insert Buttons
                                                                                                        const tracksWithInsertButtons = visibleTracks.filter(tr =>
                                                                                                            !tr.title.value.includes("Basic Folder Track") &&
                                                                                                            !tr.title.value.includes("VCA Track") &&
                                                                                                            !tr.title.value.includes("MIDI Track") &&
                                                                                                            !tr.title.value.includes("Video Track")
                                                                                                        );
                                                                                                    
                                                                                                        let tracksWithHWInserts = [];
                                                                                                    
                                                                                                        tracksWithInsertButtons.forEach(track => {
                                                                                                            let trackHasHardwareInsert = track.insertButtons.filter(btn => btn.value.invalidate().value.includes("*"))[0];
                                                                                                    
                                                                                                            let trackHasTrackspacer = track.insertButtons.filter(btn => btn.value.invalidate().value.includes("Trackspacer"))[0];
                                                                                                    
                                                                                                            if (trackHasHardwareInsert || trackHasTrackspacer) {
                                                                                                                tracksWithHWInserts.push(track);
                                                                                                            }
                                                                                                        });
                                                                                                    
                                                                                                        sf.ui.proTools.trackSelectByName({
                                                                                                            names: tracksWithHWInserts.map(th => th.normalizedTrackName),
                                                                                                            deselectOthers: true
                                                                                                        });
                                                                                                    }
                                                                                                    
                                                                                                    main();
                                                                                                    
                                                                                                    1. samuel henriques @samuel_henriques
                                                                                                        2024-03-21 14:40:07.176Z

                                                                                                        from what I can see, inserts might be getting a new nomenclature so it doesn't see the "*" or "Trackspacer" value on inserts.
                                                                                                        Another problem you might get is, if the track hight hides inserts (smaller than medium), you'll get an error and the script will break. This problem is not new.

                                                                                                        what are the insert names you are looking for?

                                                                                                        1. PPhilip weinrobe @Philip_weinrobe
                                                                                                            2024-03-21 14:42:33.556Z

                                                                                                            i am looking for "" and it's always worked up till now...
                                                                                                            i put "
                                                                                                            " into my hardware insert names, and this script basically finds all my hardware inserts.

                                                                                                            let me do a little more troubleshooting. i know about track heights and errors for this script, and i make sure the height is taller than medium

                                                                                                            1. samuel henriques @samuel_henriques
                                                                                                                2024-03-21 14:44:16.431Z

                                                                                                                your insert names still have "*" on the name?

                                                                                                                I tried it here and it finds it.

                                                                                                                PT 2024.3 on osx 13.6.4