No internet connection
  1. Home
  2. How to

Select All Basic Folders or Routing folders?

By Ben Rubin @Ben_Rubin
    2022-05-03 17:46:18.420Z

    Anyone know a way to do this? Would be great to be able to batch-process either kind of folder. Specifically for me, I want to be able to make all basic folders micro height and make all routing folder show the volume automation lane (in separate scripts).

    thanks!

    Solved in post #3, click to view
    • 8 replies
    1. Ben Rubin @Ben_Rubin
        2022-05-08 05:07:50.156Z
        1. samuel henriques @samuel_henriques
            2022-05-08 07:34:48.120Z

            Hello Ben,

            Here's "make all basic folders micro height". Let me know how it goes.

            
            
            function getCurrentTrackHeight(h) {
            
                let originalTrackHeight;
            
                switch (true) {
                    case (h <= 16):
                        originalTrackHeight = 'micro';
                        break;
                    case (h === 23):
                        originalTrackHeight = 'mini';
                        break;
                    case (h >= 43 && h <= 61):
                        originalTrackHeight = 'small';
                        break;
                    case (h >= 79 && h <= 116):
                        originalTrackHeight = 'medium';
                        break;
                    case (h >= 135 && h <= 235):
                        originalTrackHeight = 'large';
                        break;
                    case (h >= 257 && h <= 420):
                        originalTrackHeight = 'jumbo';
                        break;
                    case (h > 440):
                        originalTrackHeight = 'extreme';
                        break;
                }
                return originalTrackHeight
            };
            
            
            /**
            * @param {'micro'|'mini'|'small'|'medium'|'large'|'jumbo'|'extreme'|'fit to window' } size
            */
            function setTrackSize(size) {
                const f = sf.ui.proTools.selectedTrack.frame
            
                if (getCurrentTrackHeight(f.h) != size) {
            
                    const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                        relativePosition: { x: f.w - 10, y: 5 },
                        isOption: true,
                        isShift: true,
                    }).popupMenu;
            
                    popupMenu.menuClickPopupMenu({
                        menuPath: [size]
                    });
                }
            }
            
            function selectBasicFolders() {
                const trackHeaders = sf.ui.proTools.visibleTrackHeaders;
            
                const basicFolders = trackHeaders.filter(h => h.title.value.endsWith("- Basic Folder Track ")).map(h => h.normalizedTrackName);
            
                const firstBasicFolderTrack = sf.ui.proTools.trackGetByName({ name: basicFolders[0] }).track
            
                firstBasicFolderTrack.trackSelect();
                firstBasicFolderTrack.trackScrollToView();
            
                sf.ui.proTools.trackSelectByName({ names: basicFolders });
            
            };
            
            
            function main() {
                sf.ui.proTools.appActivateMainWindow();
                sf.ui.proTools.invalidate();
            
                selectBasicFolders();
            
                setTrackSize("micro");
            };
            
            main();
            
            Reply2 LikesSolution
            1. In reply toBen_Rubin:
              samuel henriques @samuel_henriques
                2022-05-08 08:20:44.225Z

                Here's " make all routing folder show the volume automation lane". This presumes the state of the first folder to take action, so there could be some cases it won't work as expected. Let me know how it works and we'll tweak it.

                have fun

                
                /**
                * @param {'micro'|'mini'|'small'|'medium'|'large'|'jumbo'|'extreme'|'fit to window' } size
                */
                function setTrackSize(size) {
                    const f = sf.ui.proTools.selectedTrack.frame
                
                
                    const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                        relativePosition: { x: f.w - 10, y: 5 },
                        isOption: true,
                        isShift: true,
                    }).popupMenu;
                
                    popupMenu.menuClickPopupMenu({
                        menuPath: [size]
                    });
                };
                
                
                function selectRoutingFolders() {
                    const trackHeaders = sf.ui.proTools.visibleTrackHeaders;
                
                    const routingFolders = trackHeaders.filter(h => h.title.value.endsWith("- Routing Folder Track ")).map(h => h.normalizedTrackName);
                
                    const firstBasicFolderTrack = sf.ui.proTools.trackGetByName({ name: routingFolders[0] }).track
                
                    firstBasicFolderTrack.trackSelect();
                    firstBasicFolderTrack.trackScrollToView();
                
                    sf.ui.proTools.trackSelectByName({ names: routingFolders });
                
                };
                
                
                function openAutomationLane() {
                
                    //Check if track is too small to show automation lane btn
                    const trackSize = sf.ui.proTools.selectedTrack.frame
                    trackSize.h <= 43 ? setTrackSize("small") : null;
                
                
                    const isAutomationLaneOpen = sf.ui.proTools.mainWindow.groups.allItems[111].buttons.first.invalidate().exists
                
                    if (!isAutomationLaneOpen) {
                        sf.ui.proTools.selectedTrack.children.whoseRole.is("AXDisclosureTriangle").whoseTitle.is("Show/hide automation lanes").first.mouseClickElement({
                            isOption: true,
                            isShift: true
                        });
                    }
                };
                
                
                function main() {
                    sf.ui.proTools.appActivateMainWindow();
                    sf.ui.proTools.invalidate();
                
                    selectRoutingFolders();
                
                    openAutomationLane();
                }
                
                main()
                
              • In reply toBen_Rubin:
                Ben Rubin @Ben_Rubin
                  2022-05-08 14:13:21.398Z

                  wow @samuel_henriques, thanks so much.

                  Once I added

                  sf.ui.proTools.trackDeselectAll()
                  

                  after "invalidate" in the main function, they both work great, even if tracks are already selected.

                  The Show Volume Lane script works just as you wrote it, but sorry if I was unclear, as I'd like Volume to be in the main automation lane (replacing the default "Overview",) not the automation lanes accessed by hitting the little icon. Is this possible?

                  much thanks

                  ben

                  1. In reply toBen_Rubin:
                    Ben Rubin @Ben_Rubin
                      2022-05-08 14:34:57.557Z

                      Here are my tweaks so far to the "Make all Basic Folders Micro" script.

                      I've added:
                      Store and Restore Selected Tracks
                      Switch to Edit Window if on Mix Window (and then switch back)
                      the aforementioned Deselect All Tracks just before Main Function

                      sf.ui.proTools.appActivateMainWindow();
                      sf.ui.proTools.invalidate();
                      
                      // Place the following two functions at the top of your script:
                      
                      // #1
                      function mainWindowStatus() {
                          if (sf.ui.proTools.getMenuItem('Window', 'Mix').isMenuChecked) {
                              sf.ui.proTools.menuClick({
                                  menuPath: ["Window", "Edit"],
                              });
                              return "Mix";
                          } else {
                              return "Edit";
                          }
                      }
                      
                      //#2
                      function returnToStartingMainWIndow(mainWindow) {
                          if (mainWindow == "Mix") {
                              sf.ui.proTools.menuClick({
                                  menuPath: ["Window", "Mix"],
                              });
                          }
                      }
                      
                      /// Place this line at the top of your script
                      
                      let startingWindow = mainWindowStatus();
                      
                      // Store Selected Track
                      let selectedTracks = sf.ui.proTools.selectedTrackNames;
                      
                      function getCurrentTrackHeight(h) {
                      
                          let originalTrackHeight;
                      
                          switch (true) {
                              case (h <= 16):
                                  originalTrackHeight = 'micro';
                                  break;
                              case (h === 23):
                                  originalTrackHeight = 'mini';
                                  break;
                              case (h >= 43 && h <= 61):
                                  originalTrackHeight = 'small';
                                  break;
                              case (h >= 79 && h <= 116):
                                  originalTrackHeight = 'medium';
                                  break;
                              case (h >= 135 && h <= 235):
                                  originalTrackHeight = 'large';
                                  break;
                              case (h >= 257 && h <= 420):
                                  originalTrackHeight = 'jumbo';
                                  break;
                              case (h > 440):
                                  originalTrackHeight = 'extreme';
                                  break;
                          }
                          return originalTrackHeight
                      };
                      
                      
                      /**
                      * @param {'micro'|'mini'|'small'|'medium'|'large'|'jumbo'|'extreme'|'fit to window' } size
                      */
                      function setTrackSize(size) {
                          const f = sf.ui.proTools.selectedTrack.frame
                      
                          if (getCurrentTrackHeight(f.h) != size) {
                      
                              const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                                  relativePosition: { x: f.w - 10, y: 5 },
                                  isOption: true,
                                  isShift: true,
                              }).popupMenu;
                      
                              popupMenu.menuClickPopupMenu({
                                  menuPath: [size]
                              });
                          }
                      }
                      
                      function selectBasicFolders() {
                          const trackHeaders = sf.ui.proTools.visibleTrackHeaders;
                      
                          const basicFolders = trackHeaders.filter(h => h.title.value.endsWith("- Basic Folder Track ")).map(h => h.normalizedTrackName);
                      
                          const firstBasicFolderTrack = sf.ui.proTools.trackGetByName({ name: basicFolders[0] }).track
                      
                          firstBasicFolderTrack.trackSelect();
                          firstBasicFolderTrack.trackScrollToView();
                      
                          sf.ui.proTools.trackSelectByName({ names: basicFolders });
                      
                      };
                      
                      
                      function main() {
                          sf.ui.proTools.appActivateMainWindow();
                          sf.ui.proTools.invalidate();
                      
                          sf.ui.proTools.trackDeselectAll()
                      
                          selectBasicFolders();
                      
                          setTrackSize("micro");
                      };
                      
                      main();
                      
                      // Restore Selection
                      sf.ui.proTools.trackDeselectAll();
                      
                      sf.ui.proTools.trackSelectByName({
                          names: selectedTracks,
                          deselectOthers: true,
                      });
                      
                      // end your script with this line
                      returnToStartingMainWIndow(startingWindow);
                      
                      1. In reply toBen_Rubin:
                        Ben Rubin @Ben_Rubin
                          2022-05-08 20:02:50.394Z

                          Realizing, of course, there will be little reason to start this script from the Mix Window, but hey, the capability is there.

                          So here is my version of the script to make all Routing Folders show Volume on its main Display Lane. Getting all the tracks to change to Volume is super-easy by just using "-" w Command Focus enabled.

                          sf.ui.proTools.appActivateMainWindow();
                          sf.ui.proTools.invalidate();
                          
                          // Place the following two functions at the top of your script:
                          
                          // #1
                          function mainWindowStatus() {
                              if (sf.ui.proTools.getMenuItem('Window', 'Mix').isMenuChecked) {
                                  sf.ui.proTools.menuClick({
                                      menuPath: ["Window", "Edit"],
                                  });
                                  return "Mix";
                              } else {
                                  return "Edit";
                              }
                          }
                          
                          //#2
                          function returnToStartingMainWIndow(mainWindow) {
                              if (mainWindow == "Mix") {
                                  sf.ui.proTools.menuClick({
                                      menuPath: ["Window", "Mix"],
                                  });
                              }
                          }
                          
                          /// Place this line at the top of your script
                          
                          let startingWindow = mainWindowStatus();
                          // Store Selected Track
                          let selectedTracks = sf.ui.proTools.selectedTrackNames;
                          
                          /**
                          * @param {'micro'|'mini'|'small'|'medium'|'large'|'jumbo'|'extreme'|'fit to window' } size
                          */
                          function setTrackSize(size) {
                              const f = sf.ui.proTools.selectedTrack.frame
                          
                          
                              const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                                  relativePosition: { x: f.w - 10, y: 5 },
                                  isOption: true,
                                  isShift: true,
                              }).popupMenu;
                          
                              popupMenu.menuClickPopupMenu({
                                  menuPath: [size]
                              });
                          };
                          
                          function selectRoutingFolders() {
                              const trackHeaders = sf.ui.proTools.visibleTrackHeaders;
                          
                              const routingFolders = trackHeaders.filter(h => h.title.value.endsWith("- Routing Folder Track ")).map(h => h.normalizedTrackName);
                          
                              const firstBasicFolderTrack = sf.ui.proTools.trackGetByName({ name: routingFolders[0] }).track
                          
                              firstBasicFolderTrack.trackSelect();
                              firstBasicFolderTrack.trackScrollToView();
                          
                              sf.ui.proTools.trackSelectByName({ names: routingFolders });
                          };
                          
                          
                          function main() {
                              sf.ui.proTools.appActivateMainWindow();
                              sf.ui.proTools.invalidate();
                          
                          sf.ui.proTools.trackDeselectAll()
                          
                              selectRoutingFolders();
                          
                              sf.keyboard.press({
                                  keys: "minus",
                              });
                          }
                          
                          main()
                          
                          // Restore Selection
                          sf.ui.proTools.trackDeselectAll();
                          
                          sf.ui.proTools.trackSelectByName({
                              names: selectedTracks,
                              deselectOthers: true,
                          });
                          
                          // end your script with this line
                          returnToStartingMainWIndow(startingWindow);
                          

                          Thanks again for your help, @samuel_henriques!!! Any ideas about tackling this one:
                          Show only active automation lanes on a selected track?

                          1. samuel henriques @samuel_henriques
                              2022-05-08 20:07:11.673Z

                              Great job, just to make sure, are you all set with his script?

                              1. Ben Rubin @Ben_Rubin
                                  2022-05-09 12:38:37.244Z

                                  yes! i'm all set on this one. Thanks so much!