No internet connection
  1. Home
  2. How to

Can someone help modify @Andrew_Scheps script to accommodate Multiple Output Assignments?

By Gary Philips @Gary_Philips
    2022-01-09 22:47:50.050Z

    Hi, brand new here and I'd love to find a way to modify Andrew's script to work with multiple outputs. For instance, 4 guitar tracks which are all routed to outputs BusA & BusB, moved into a new routing folder called GTRS, with the guitar tracks routed to the folder and the folder routed to BusA & BusB.
    Can anyone break it down for me? Thank you!

    // Get Name for New Folder - Keep in mind this will also be the name of the busses used to route the tracks
    var folderTitle = sf.interaction.popupText({ title: 'Name of New Folder' }).text;
    
    
    sf.ui.proTools.appActivateMainWindow();
    // Refresh PTs track list
    sf.ui.proTools.mainWindow.invalidate();
    
    // Set up variables to hold original assignments. NOTE this will only check the top-most selected track
    //Variable to store the current output assignment
    var originalOutput = sf.ui.proTools.selectedTrack.outputPathButton.value.invalidate().value;
    
    
    
    // Open Move to New Folder dialog and set parameters
    sf.ui.proTools.menuClick({
        menuPath: ["Track", "Move to New Folder..."],
    });
    
     sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
            waitType: "Appear",
            timeout: 2500,
        });
    let folderDlg = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first;
    let popupButtons = folderDlg.popupButtons;
    
    //Assign the buttons coming out of the previous instruction to individual variables
    var folderType = popupButtons[0];
    
    if (folderType.value.invalidate().value != 'Routing Folder')
        folderType.popupMenuSelect({ menuPath: ['Routing Folder'] });
    
    //Now that it's definitely a routing folder we have the other two popup menus available to assign to variables
    
    var folderWidth = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[2];
    var timeBase = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[1];
    
    // Set them accordingly
    
    if (folderWidth.value.value != 'Stereo')
        folderWidth.popupMenuSelect({ menuPath: ['Stereo'] });
    
    if (timeBase.value.value != 'Samples')
        timeBase.popupMenuSelect({ menuPath: ['Samples'] });
    
    sf.ui.proTools.windows.whoseTitle.is('Move to New Folder').first.checkBoxes.whoseTitle.is('Route Tracks to New Folder').first.checkboxSet({
        targetValue: "Enable",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.textFields.whoseTitle.is('Track name').first.elementSetTextFieldWithAreaValue({
        value: folderTitle,
    });
    
    // Make it so
    sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.buttons.whoseTitle.is('Create').first.elementClick();
    sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
        waitType: "Disappear",
        timeout: 2000,
    });
    // Refresh PTs track list
    sf.ui.proTools.mainWindow.invalidate();
    //Reselect the new folder
    sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: [folderTitle] });
    
    
    // Folder will automatically be assigned to the session's default output
    // If the source track's output was different assign it to the original output unless it was hardware
    if (originalOutput !== "MIX") {
        sf.ui.proTools.selectedTrack.trackOutputSelect({
            outputSelector: items => items.filter(item => item.path[0] === "bus" && item.path.slice(-1)[0] === originalOutput + " (Stereo)")[0],
            //skipWhenValueIs: 'Mix Buss',
            selectForAllSelectedTracks: true,
        }, function (wasHardware) {
            log( "Original output was Hardware");
        });
    }
    
    • 20 replies

    There are 20 replies. Estimated reading time: 33 minutes

    1. Andrew Scheps @Andrew_Scheps
        2022-01-10 15:22:29.835Z

        Ok, here you go! This has also been refactored a bit so it isn't just one huge blob of code.

        Please note that the folder will always be assigned to the outputs of the top-most selected track when you run the script.

        
        
        function makeNewFolder(folderTitle) {
            // Open Move to New Folder dialog and set parameters
            sf.ui.proTools.menuClick({
                menuPath: ["Track", "Move to New Folder..."],
            });
        
            sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
                waitType: "Appear",
                timeout: 2500,
            });
            let folderDlg = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first;
            let popupButtons = folderDlg.popupButtons;
        
            //Assign the buttons coming out of the previous instruction to individual variables
            var folderType = popupButtons[0];
        
            if (folderType.value.invalidate().value != 'Routing Folder')
                folderType.popupMenuSelect({ menuPath: ['Routing Folder'] });
        
            //Now that it's definitely a routing folder we have the other two popup menus available to assign to variables
        
            var folderWidth = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[2];
            var timeBase = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[1];
        
            // Set them accordingly
        
            if (folderWidth.value.value != 'Stereo')
                folderWidth.popupMenuSelect({ menuPath: ['Stereo'] });
        
            if (timeBase.value.value != 'Samples')
                timeBase.popupMenuSelect({ menuPath: ['Samples'] });
        
            sf.ui.proTools.windows.whoseTitle.is('Move to New Folder').first.checkBoxes.whoseTitle.is('Route Tracks to New Folder').first.checkboxSet({
                targetValue: "Enable",
            });
        
            sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.textFields.whoseTitle.is('Track name').first.elementSetTextFieldWithAreaValue({
                value: folderTitle,
            });
        
            // Make it so
            sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.buttons.whoseTitle.is('Create').first.elementClick();
            //If there were multiple outputs assigned to any rtrack in the selection we will get a further diaslog
            if (sf.ui.proTools.confirmationDialog && sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").exists) {
                sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").first.elementClick();
                sf.ui.proTools.confirmationDialog.elementWaitFor({ waitType: "Disappear" })
            }
            sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
                waitType: "Disappear",
                timeout: 2000,
            });
        
        
        }
        
        function reAssignFolderOutputs(originalOutputs, folderTitle) {
        
            // Refresh PTs track list
            sf.ui.proTools.mainWindow.invalidate();
            //Reselect the new folder
            sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: [folderTitle] });
        
        
            //Assign the folder output to the outputs of the first originally selected track
        
            for (let i = 0; i < originalOutputs.length; i++) {
                sf.ui.proTools.selectedTrack.outputPathButton.popupMenuSelect({
                    menuPath: originalOutputs[i],
                    isControl: i > 0,
        
                })
            }
        }
        
        function getOutputAssignments() {
            // Set up variables to hold original assignments. NOTE this will only check the top-most selected track
            //Variable to store the current output assignment
            let originalOutputs = sf.ui.proTools.selectedTrack.outputPathButton.popupMenuFetchAllItems().menuItems.filter(mi => mi.element.isMenuChecked).map(ci => ci.names);
            sf.ui.proTools.appActivateMainWindow();
            return originalOutputs
        }
        
        function main() {
        
            // Get Name for New Folder - Keep in mind this will also be the name of the busses used to route the tracks
            var folderTitle = sf.interaction.popupText({ title: 'Name of New Folder' }).text;
        
        
            sf.ui.proTools.appActivateMainWindow();
            // Refresh PTs track list
            sf.ui.proTools.mainWindow.invalidate();
        
            let originalOutputs = getOutputAssignments();
        
            makeNewFolder(folderTitle);
        
            reAssignFolderOutputs(originalOutputs, folderTitle);
        
        
        }
        
        main();
        
        1. Gary Philips @Gary_Philips
            2022-01-10 21:55:42.934Z

            Andrew, thank you so much for doing this. I'm getting a weird result though. I see soundflow change the output of the new folder track, then add the 2nd output (the "+"). Then I can see it remove the first output (no more "+", just the 2nd output.) Then it removes that output and finishes with the folder track set to No Output. Wish I were better at reading the code, but I'm just getting started here. . .

            Here's what my log shows:

            10.01.2022 13:53:04.25 [Backend]: Run command: user:default:cky97bm7p000gs4102ozi0va0

            10.01.2022 13:53:04.25 [Backend]: #StreamDeck: deck-button-click -> Move to New ƒ + Multiple Outputs
            Validating command... user:default:cky97bm7p000gs4102ozi0va0
            Invoking command...user:default:cky97bm7p000gs4102ozi0va0

            Command: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]
            Sending event /popup/open with subject: ToAgent...

            10.01.2022 13:53:04.25 [Application]: openPopupWindow
            10.01.2022 13:53:06.84 [Backend]: [SF_FIREBASE_WS]: Sending keep-alive

            10.01.2022 13:53:11.48 [Backend]: Sending event /popup/close with subject: ToAgent...

            10.01.2022 13:53:11.48 [Application]: closePopupWindow
            10.01.2022 13:53:11.49 [Application]: this.popupWindow.on(blur)
            10.01.2022 13:53:11.49 [Application]: this.popupWindow.on(hide)
            10.01.2022 13:53:11.77 [Backend]: Clicking with mouse here: 1990, 28

            10.01.2022 13:53:11.95 [Backend]: Clicking with mouse here: 494, 843

            10.01.2022 13:53:12.05 [Backend]: PopupMenu full role:AXMenu

            10.01.2022 13:53:12.26 [Backend]: Clicking with mouse here: 72, 30

            10.01.2022 13:53:12.53 [Backend]: ProTools version: 21.12.0.97 class: PT2021_6
            ProTools processID: 1675

            10.01.2022 13:53:12.56 [Backend]: ProTools version: 21.12.0.97 class: PT2021_6
            ProTools processID: 1675

            10.01.2022 13:53:16.66 [Backend]: Clicking with mouse here: 494, 849

            10.01.2022 13:53:16.72 [Backend]: PopupMenu full role:AXMenu

            10.01.2022 13:53:16.72 [Backend]: Clicking popup menu element: bus

            10.01.2022 13:53:16.76 [Backend]: Clicking popup menu element: BMixBus (Stereo)

            10.01.2022 13:53:17.91 [Backend]: Clicking with mouse here: 494, 849

            10.01.2022 13:53:17.95 [Backend]: PopupMenu full role:AXMenu

            10.01.2022 13:53:17.95 [Backend]: Clicking popup menu element: bus

            10.01.2022 13:53:17.100 [Backend]: Clicking popup menu element: DMixBus (Stereo)

            10.01.2022 13:53:19.12 [Backend]: Clicking with mouse here: 494, 849

            10.01.2022 13:53:19.18 [Backend]: PopupMenu full role:AXMenu

            10.01.2022 13:53:19.18 [Backend]: Clicking popup menu element: Stereo

            10.01.2022 13:53:19.21 [Backend]: Clicking popup menu element: bus

            10.01.2022 13:53:19.24 [Backend]: Clicking popup menu element: BMixBus

            10.01.2022 13:53:20.40 [Backend]: Clicking with mouse here: 494, 849

            10.01.2022 13:53:20.43 [Backend]: PopupMenu full role:AXMenu

            10.01.2022 13:53:20.44 [Backend]: Clicking popup menu element: Stereo

            10.01.2022 13:53:20.46 [Backend]: Clicking popup menu element: bus

            10.01.2022 13:53:20.49 [Backend]: Clicking popup menu element: DMixBus

            10.01.2022 13:53:20.49 [Backend]: << Command: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]

            1. Andrew Scheps @Andrew_Scheps
                2022-01-10 22:42:04.503Z

                Hmmm, very strange, it was working here this afternoon. Let me see what's going on

                1. Andrew Scheps @Andrew_Scheps
                    2022-01-10 23:12:03.063Z

                    It's assigning each output twice (which of course unassigns them the second time). If you look at the output menu for the track when they're assigned properly are the outputs listed twice somehow?

                    1. Andrew Scheps @Andrew_Scheps
                        2022-01-10 23:17:07.490Z

                        After the line:

                        let originalOutputs = getOutputAssignments();
                        

                        please add

                        log({originalOutputs});
                        

                        and send me the log?

                        To format the log better, type three back-ticks (right under the escape key), hit return, then paste the bit of the log that's relevant), then do three more back-ticks to go back to normal text.

                        1. Gary Philips @Gary_Philips
                            2022-01-10 23:27:42.248Z

                            apologies for bad formatting. Learning :-) . . . Here is the log from the last run (failed):

                            
                            10.01.2022 15:25:02.97 <info> [Backend]: Run command: user:default:cky97bm7p000gs4102ozi0va0
                            #StreamDeck: deck-button-click -> Move to New ƒ + Multiple Outputs
                            Validating command... user:default:cky97bm7p000gs4102ozi0va0
                            Invoking command...user:default:cky97bm7p000gs4102ozi0va0
                            
                            10.01.2022 15:25:02.97 <info> [Backend]: >> Command: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]
                            Sending event /popup/open with subject: ToAgent...
                            
                            10.01.2022 15:25:02.97 <info> [Application]: openPopupWindow
                            10.01.2022 15:25:08.55 <info> [Backend]: Sending event /popup/close with subject: ToAgent...
                            
                            10.01.2022 15:25:08.55 <info> [Application]: closePopupWindow
                            10.01.2022 15:25:08.56 <info> [Application]: this.popupWindow.on(blur)
                            10.01.2022 15:25:08.57 <info> [Application]: this.popupWindow.on(hide)
                            10.01.2022 15:25:08.84 <info> [Backend]: Clicking with mouse here: 72, 30
                            
                            10.01.2022 15:25:08.99 <info> [Backend]: Clicking with mouse here: 509, 792
                            
                            10.01.2022 15:25:09.03 <info> [Backend]: PopupMenu full role:AXMenu
                            
                            10.01.2022 15:25:09.19 <info> [Backend]: Clicking with mouse here: 72, 30
                            
                            10.01.2022 15:25:09.21 <info> [Backend]: JavaScript error with InnerException: null
                            !! Command Error: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]:
                            ReferenceError: originalOuputs is not defined
                            (Move to New ƒ + Multiple Outputs line 95) 
                            
                            
                            10.01.2022 15:25:09.21 <info> [Backend]: << Command: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]
                            
                            10.01.2022 15:25:17.41 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive
                            
                            
                            1. Andrew Scheps @Andrew_Scheps
                                2022-01-10 23:35:46.516Z

                                There was a typo in my original post, I've corrected it. Could you replace that line again and re-run?

                                Should be:

                                log({originalOutputs});
                                
                                
                                1. Gary Philips @Gary_Philips
                                    2022-01-11 06:07:06.859Z

                                    oops, I should have at least caught that. . . . here is the log with the corrected code:

                                    0.01.2022 22:05:17.06 <info> [Backend]: Run command: user:default:cky97bm7p000gs4102ozi0va0
                                    #StreamDeck: deck-button-click -> Move to New ƒ + Multiple Outputs
                                    Validating command... user:default:cky97bm7p000gs4102ozi0va0
                                    Invoking command...user:default:cky97bm7p000gs4102ozi0va0
                                    
                                    10.01.2022 22:05:17.06 <info> [Backend]: >> Command: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]
                                    
                                    10.01.2022 22:05:17.06 <info> [Application]: openPopupWindow
                                    10.01.2022 22:05:17.07 <info> [Backend]: Sending event /popup/open with subject: ToAgent...
                                    
                                    10.01.2022 22:05:21.15 <info> [Backend]: Sending event /popup/close with subject: ToAgent...
                                    
                                    10.01.2022 22:05:21.15 <info> [Application]: closePopupWindow
                                    10.01.2022 22:05:21.15 <info> [Application]: this.popupWindow.on(blur)
                                    10.01.2022 22:05:21.16 <info> [Application]: this.popupWindow.on(hide)
                                    10.01.2022 22:05:21.44 <info> [Backend]: Clicking with mouse here: 72, 30
                                    
                                    10.01.2022 22:05:21.59 <info> [Backend]: Clicking with mouse here: 509, 792
                                    
                                    10.01.2022 22:05:21.63 <info> [Backend]: PopupMenu full role:AXMenu
                                    
                                    10.01.2022 22:05:21.79 <info> [Backend]: Clicking with mouse here: 72, 30
                                    
                                    10.01.2022 22:05:21.82 <info> [Backend]: [LOG] {
                                        "originalOutputs": [
                                            [
                                                "bus",
                                                "CMixBus (Stereo)"
                                            ],
                                            [
                                                "bus",
                                                "DMixBus (Stereo)"
                                            ],
                                            [
                                                "Stereo",
                                                "bus",
                                                "CMixBus"
                                            ],
                                            [
                                                "Stereo",
                                                "bus",
                                                "DMixBus"
                                            ]
                                        ]
                                    }
                                    
                                    10.01.2022 22:05:22.04 <info> [Backend]: ProTools version: 21.12.0.97 class: PT2021_6
                                    ProTools processID: 1675
                                    
                                    10.01.2022 22:05:22.07 <info> [Backend]: ProTools version: 21.12.0.97 class: PT2021_6
                                    ProTools processID: 1675
                                    
                                    10.01.2022 22:05:22.31 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive
                                    
                                    10.01.2022 22:05:25.45 <info> [Backend]: Clicking with mouse here: 509, 798
                                    
                                    10.01.2022 22:05:25.50 <info> [Backend]: PopupMenu full role:AXMenu
                                    
                                    10.01.2022 22:05:25.50 <info> [Backend]: Clicking popup menu element: bus
                                    
                                    10.01.2022 22:05:25.55 <info> [Backend]: Clicking popup menu element: CMixBus (Stereo)
                                    
                                    10.01.2022 22:05:26.70 <info> [Backend]: Clicking with mouse here: 509, 798
                                    
                                    10.01.2022 22:05:26.73 <info> [Backend]: PopupMenu full role:AXMenu
                                    
                                    10.01.2022 22:05:26.73 <info> [Backend]: Clicking popup menu element: bus
                                    
                                    10.01.2022 22:05:26.76 <info> [Backend]: Clicking popup menu element: DMixBus (Stereo)
                                    
                                    10.01.2022 22:05:27.90 <info> [Backend]: Clicking with mouse here: 509, 798
                                    
                                    10.01.2022 22:05:27.93 <info> [Backend]: PopupMenu full role:AXMenu
                                    
                                    10.01.2022 22:05:27.93 <info> [Backend]: Clicking popup menu element: Stereo
                                    
                                    10.01.2022 22:05:27.95 <info> [Backend]: Clicking popup menu element: bus
                                    
                                    10.01.2022 22:05:27.98 <info> [Backend]: Clicking popup menu element: CMixBus
                                    
                                    10.01.2022 22:05:29.14 <info> [Backend]: Clicking with mouse here: 509, 798
                                    
                                    10.01.2022 22:05:29.18 <info> [Backend]: PopupMenu full role:AXMenu
                                    
                                    10.01.2022 22:05:29.18 <info> [Backend]: Clicking popup menu element: Stereo
                                    
                                    10.01.2022 22:05:29.20 <info> [Backend]: Clicking popup menu element: bus
                                    
                                    10.01.2022 22:05:29.23 <info> [Backend]: Clicking popup menu element: DMixBus
                                    
                                    10.01.2022 22:05:29.23 <info> [Backend]: << Command: Move to New ƒ + Multiple Outputs [user:default:cky97bm7p000gs4102ozi0va0]
                                    
                                    
                                    1. Andrew Scheps @Andrew_Scheps
                                        2022-01-11 09:01:09.872Z

                                        Yeah, you can see they’re listed twice, which is really weird! Is there any way you could take a screen shot of the output menu?

                                        1. Gary Philips @Gary_Philips
                                            2022-01-11 09:12:36.467Z

                                            Like the pop up menu in the mix window? or you mean the actual I/O setup?

                                            1. Andrew Scheps @Andrew_Scheps
                                                2022-01-11 09:16:59.396Z

                                                Whatever will show me why the outputs are showing up twice in those menus. Not sure really. The output menu on the track is probably the way to go, a picture of each submenu

                                                1. Gary Philips @Gary_Philips
                                                    2022-01-11 09:22:28.613Z

                                                    how bout these?

                                                    1. Andrew Scheps @Andrew_Scheps
                                                        2022-01-11 09:28:25.810Z

                                                        Hmmm, I’m not in front of my Pro Tools rig, but I’ll try and figure this out later.

                                                        1. Gary Philips @Gary_Philips
                                                            2022-01-11 09:31:33.721Z

                                                            Thanks Andrew -- that'll give me a good excuse to go to sleep too. lol.

                                                          • In reply toGary_Philips:
                                                            Andrew Scheps @Andrew_Scheps
                                                              2022-01-11 10:15:56.809Z

                                                              Aha! You have the preference set so the I/O menu is showing your Outputs sorted by type and by width. That explains seeing the output and bus sub-menus as well as mono and stereo sub-menus. It means that every output is listed twice in the menu. I don't think I've ever seen anybody using that pref before! I'll just ignore the track width sub menus.

                                                              1. Andrew Scheps @Andrew_Scheps
                                                                  2022-01-11 10:21:14.121Z

                                                                  Here's the one that will work with your I/O display. This will also work if you show I/O only by type. The script won't work if you show only by width but I've never seen anybody use Pro Tools that way. To be honest I've never seen anybody show them by width before either. Learn something new every day!

                                                                  
                                                                  function makeNewFolder(folderTitle) {
                                                                      // Open Move to New Folder dialog and set parameters
                                                                      sf.ui.proTools.menuClick({
                                                                          menuPath: ["Track", "Move to New Folder..."],
                                                                      });
                                                                  
                                                                      sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
                                                                          waitType: "Appear",
                                                                          timeout: 2500,
                                                                      });
                                                                      let folderDlg = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first;
                                                                      let popupButtons = folderDlg.popupButtons;
                                                                  
                                                                      //Assign the buttons coming out of the previous instruction to individual variables
                                                                      var folderType = popupButtons[0];
                                                                  
                                                                      if (folderType.value.invalidate().value != 'Routing Folder')
                                                                          folderType.popupMenuSelect({ menuPath: ['Routing Folder'] });
                                                                  
                                                                      //Now that it's definitely a routing folder we have the other two popup menus available to assign to variables
                                                                  
                                                                      var folderWidth = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[2];
                                                                      var timeBase = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[1];
                                                                  
                                                                      // Set them accordingly
                                                                  
                                                                      if (folderWidth.value.value != 'Stereo')
                                                                          folderWidth.popupMenuSelect({ menuPath: ['Stereo'] });
                                                                  
                                                                      if (timeBase.value.value != 'Samples')
                                                                          timeBase.popupMenuSelect({ menuPath: ['Samples'] });
                                                                  
                                                                      sf.ui.proTools.windows.whoseTitle.is('Move to New Folder').first.checkBoxes.whoseTitle.is('Route Tracks to New Folder').first.checkboxSet({
                                                                          targetValue: "Enable",
                                                                      });
                                                                  
                                                                      sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.textFields.whoseTitle.is('Track name').first.elementSetTextFieldWithAreaValue({
                                                                          value: folderTitle,
                                                                      });
                                                                  
                                                                      // Make it so
                                                                      sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.buttons.whoseTitle.is('Create').first.elementClick();
                                                                      //If there were multiple outputs assigned to any rtrack in the selection we will get a further diaslog
                                                                      if (sf.ui.proTools.confirmationDialog && sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").exists) {
                                                                          sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").first.elementClick();
                                                                          sf.ui.proTools.confirmationDialog.elementWaitFor({ waitType: "Disappear" })
                                                                      }
                                                                      sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
                                                                          waitType: "Disappear",
                                                                          timeout: 2000,
                                                                      });
                                                                  
                                                                  
                                                                  }
                                                                  
                                                                  function reAssignFolderOutputs(originalOutputs, folderTitle) {
                                                                  
                                                                      // Refresh PTs track list
                                                                      sf.ui.proTools.mainWindow.invalidate();
                                                                      //Reselect the new folder
                                                                      sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: [folderTitle] });
                                                                  
                                                                  
                                                                      //Assign the folder output to the outputs of the first originally selected track
                                                                      //Only allow setting from the output and bus sub-menus to avoid duplication
                                                                  
                                                                      for (let i = 0; i < originalOutputs.length; i++) {
                                                                          if (originalOutputs[i][0] === 'output' || originalOutputs[i][0] === 'bus') {
                                                                              sf.ui.proTools.selectedTrack.outputPathButton.popupMenuSelect({
                                                                                  menuPath: originalOutputs[i],
                                                                                  isControl: i > 0,
                                                                              });
                                                                          }
                                                                      }
                                                                  }
                                                                  
                                                                  function getOutputAssignments() {
                                                                      // Set up variables to hold original assignments. NOTE this will only check the top-most selected track
                                                                      //Variable to store the current output assignment
                                                                      let originalOutputs = sf.ui.proTools.selectedTrack.outputPathButton.popupMenuFetchAllItems().menuItems.filter(mi => mi.element.isMenuChecked).map(ci => ci.names);
                                                                      sf.ui.proTools.appActivateMainWindow();
                                                                      return originalOutputs
                                                                  }
                                                                  
                                                                  function main() {
                                                                  
                                                                      // Get Name for New Folder - Keep in mind this will also be the name of the busses used to route the tracks
                                                                      var folderTitle = sf.interaction.popupText({ title: 'Name of New Folder' }).text;
                                                                  
                                                                  
                                                                      sf.ui.proTools.appActivateMainWindow();
                                                                      // Refresh PTs track list
                                                                      sf.ui.proTools.mainWindow.invalidate();
                                                                  
                                                                      let originalOutputs = getOutputAssignments();
                                                                  
                                                                      makeNewFolder(folderTitle);
                                                                  
                                                                      reAssignFolderOutputs(originalOutputs, folderTitle);
                                                                  
                                                                  
                                                                  }
                                                                  
                                                                  main();
                                                                  
                                                                  1. Gary Philips @Gary_Philips
                                                                      2022-01-12 02:53:46.771Z

                                                                      That pref is set completely unintentionally -- not sure how it got that way as I never actually use those menus. . . . Ugh, sorry that was causing the issues. I'm going to set the pref to type only rn. And then I'll give this a whirl. thank you!

                                                                      1. Gary Philips @Gary_Philips
                                                                          2022-01-12 02:59:47.144Z

                                                                          YES YES YES. Working like a charm. THIS is what got me to soundflow.org. I'm sold. Thank you. Andrew, I owe you lunch next time you're around Malibu!

                                                    2. In reply toAndrew_Scheps:
                                                      Andrew Scheps @Andrew_Scheps
                                                        2022-01-10 23:21:34.759Z

                                                        And of course it doesn't do it here, working as expected...

                                                2. In reply toGary_Philips:
                                                  Gary Philips @Gary_Philips
                                                    2022-02-03 04:56:21.355Z

                                                    I'm using the HELLLLLL out of this script, Andrew. Thank you :-)
                                                    Could anyone help me with making the new folder track color match the color of the original tracks?

                                                    function makeNewFolder(folderTitle) {
                                                        // Open Move to New Folder dialog and set parameters
                                                        sf.ui.proTools.menuClick({
                                                            menuPath: ["Track", "Move to New Folder..."],
                                                        });
                                                    
                                                        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
                                                            waitType: "Appear",
                                                            timeout: 2500,
                                                        });
                                                        let folderDlg = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first;
                                                        let popupButtons = folderDlg.popupButtons;
                                                    
                                                        //Assign the buttons coming out of the previous instruction to individual variables
                                                        var folderType = popupButtons[0];
                                                    
                                                        if (folderType.value.invalidate().value != 'Routing Folder')
                                                            folderType.popupMenuSelect({ menuPath: ['Routing Folder'] });
                                                    
                                                        //Now that it's definitely a routing folder we have the other two popup menus available to assign to variables
                                                    
                                                        var folderWidth = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[2];
                                                        var timeBase = sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.popupButtons.allItems[1];
                                                    
                                                        // Set them accordingly
                                                    
                                                        if (folderWidth.value.value != 'Stereo')
                                                            folderWidth.popupMenuSelect({ menuPath: ['Stereo'] });
                                                    
                                                        if (timeBase.value.value != 'Ticks')
                                                            timeBase.popupMenuSelect({ menuPath: ['Ticks'] });
                                                    
                                                        sf.ui.proTools.windows.whoseTitle.is('Move to New Folder').first.checkBoxes.whoseTitle.is('Route Tracks to New Folder').first.checkboxSet({
                                                            targetValue: "Enable",
                                                        });
                                                    
                                                        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.textFields.whoseTitle.is('Track name').first.elementSetTextFieldWithAreaValue({
                                                            value: folderTitle,
                                                        });
                                                    
                                                        // Make it so
                                                        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.buttons.whoseTitle.is('Create').first.elementClick();
                                                        //If there were multiple outputs assigned to any rtrack in the selection we will get a further diaslog
                                                        if (sf.ui.proTools.confirmationDialog && sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").exists) {
                                                            sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("Replace").first.elementClick();
                                                            sf.ui.proTools.confirmationDialog.elementWaitFor({ waitType: "Disappear" })
                                                        }
                                                        sf.ui.proTools.windows.whoseTitle.is('Move To New Folder').first.elementWaitFor({
                                                            waitType: "Disappear",
                                                            timeout: 2000,
                                                        });
                                                    
                                                    
                                                    }
                                                    
                                                    function reAssignFolderOutputs(originalOutputs, folderTitle) {
                                                    
                                                        // Refresh PTs track list
                                                        sf.ui.proTools.mainWindow.invalidate();
                                                        //Reselect the new folder
                                                        sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: [folderTitle] });
                                                    
                                                    
                                                        //Assign the folder output to the outputs of the first originally selected track
                                                        //Only allow setting from the output and bus sub-menus to avoid duplication
                                                    
                                                        for (let i = 0; i < originalOutputs.length; i++) {
                                                            if (originalOutputs[i][0] === 'output' || originalOutputs[i][0] === 'bus') {
                                                                sf.ui.proTools.selectedTrack.outputPathButton.popupMenuSelect({
                                                                    menuPath: originalOutputs[i],
                                                                    isControl: i > 0,
                                                                });
                                                            }
                                                        }
                                                    }
                                                    
                                                    function getOutputAssignments() {
                                                        // Set up variables to hold original assignments. NOTE this will only check the top-most selected track
                                                        //Variable to store the current output assignment
                                                        let originalOutputs = sf.ui.proTools.selectedTrack.outputPathButton.popupMenuFetchAllItems().menuItems.filter(mi => mi.element.isMenuChecked).map(ci => ci.names);
                                                        sf.ui.proTools.appActivateMainWindow();
                                                        return originalOutputs
                                                    }
                                                    
                                                    function main() {
                                                    
                                                        // Get Name for New Folder - Keep in mind this will also be the name of the busses used to route the tracks
                                                        var folderTitle = sf.interaction.popupText({ title: 'Name of New Folder' }).text;
                                                    
                                                    
                                                        sf.ui.proTools.appActivateMainWindow();
                                                        // Refresh PTs track list
                                                        sf.ui.proTools.mainWindow.invalidate();
                                                    
                                                        let originalOutputs = getOutputAssignments();
                                                    
                                                        makeNewFolder(folderTitle);
                                                    
                                                        reAssignFolderOutputs(originalOutputs, folderTitle);
                                                    
                                                    
                                                    }
                                                    
                                                    main();