No internet connection
  1. Home
  2. How to

Routing selected tracks to aux/routing folder - Manually naming the bus?

By Fannar Magnusson @Fannar_Magnusson
    2021-08-27 12:55:48.448Z

    Hi. I was wondering if someone would help me with creating a macro that:

    1.) Takes selected tracks and routes their outputs to a new aux track OR new routing track
    2.) Leaves the name box open for me to manually name each bus I use this macro with..
    3.) Leaves the name box open for me to manually name each new aux track/routing folder this macro creates

    a) I would like to able to let the macro first hang on the name box for the newly created bus so I can name the bus like 'guitar 1', 'guitar2' etc and not have it just choose a random bus (bus 19-20 etc) and have that name.
    b) I would then like Pro Tools to open up the name box of the new aux/routing folder so I can name it manually AFTER I have named the bus that the macro will have created.

    Is this possible via SoundFlow?

    • 15 replies

    There are 15 replies. Estimated reading time: 14 minutes

    1. Chris Shaw @Chris_Shaw2021-08-27 17:14:56.923Z2021-08-28 02:00:22.615Z

      Instead of having the macro/script hang at each part of the naming process it's easier to get all of that info from the user up front, then create the track with that info.

      Something like this:

      sf.ui.proTools.appActivateMainWindow();
      
      // if visible, hide floating windows
      const areFloatingWindowsVisible = sf.ui.proTools.getMenuItem('Window', 'Hide All Floating Windows').isEnabled
      if (areFloatingWindowsVisible) {
          sf.ui.proTools.menuClick({ menuPath: ['Window', 'Hide All Floating Windows'] })
      };
      
      /// store selected track names
      const selectedTracks = sf.ui.proTools.selectedTrackNames
      
      // Try making new Routing/Aux track
      try {
      
          // define track output selector
          const audioOutput = sf.ui.proTools.selectedTrack.groups.whoseTitle.is("Audio IO")
          const trackOutput = audioOutput.first.popupButtons.allItems[1]
      
          // get ouput of first track
          var outputPaths = trackOutput.popupMenuFetchAllItems().menuItems
          const outputPath = outputPaths.map((mi, i) => ({ menuItem: mi, index: i })).filter(m => m.menuItem.element.isMenuChecked)[0].menuItem.path;
      
          // Get track and bus info from user
          var trackType = sf.interaction.displayDialog({
              buttons: ["Cancel", "Routing Folder", "Aux Input"],
              defaultButton: 'Routing Folder',
              prompt: "Which do you want to create?",
          }).button;
      
          var trackWidth = sf.interaction.displayDialog({
              buttons: ["Cancel", "Stereo", "Mono"],
              defaultButton: 'Stereo',
              prompt: "New Track Width?",
          }).button;
      
          var busName = sf.interaction.popupText({
              title: "Bus Name",
          }).text;
      
          var newTrackName = sf.interaction.popupText({
              title: "Folder / Aux Track Name",
          }).text;
      
          var makeGroup = sf.interaction.displayDialog({
              buttons: ["Cancel", "No", "Yes"],
              defaultButton: 'Yes',
              prompt: "Group tracks when done?",
          }).button;
      
          if (makeGroup == 'Yes') {
              var groupName = sf.interaction.popupText({
                  title: "Group Name",
              }).text;
          }
      
          sf.ui.proTools.appActivateMainWindow();
      
          // If selected, create new Aux track
          if (trackType == "Aux Input") {
              sf.ui.proTools.menuClick({
                  menuPath: ['Track', 'New...']
              });
      
              const newTrackWin = sf.ui.proTools.windows.whoseTitle.is("New Tracks").first
      
              newTrackWin.elementWaitFor();
      
              newTrackWin.popupButtons.whoseDescription.is("Track format").first.popupMenuSelect({
                  menuPath: [trackWidth]
              });
      
              newTrackWin.popupButtons.whoseDescription.is("Track type").first.popupMenuSelect({
                  menuPath: [trackType]
              });
      
              newTrackWin.textFields.whoseTitle.is("Track Name").first.elementClick();
      
              newTrackWin.textFields.whoseTitle.is("Track Name").first.elementSetTextFieldWithAreaValue({
                  value: newTrackName,
              });
              newTrackWin.buttons.whoseTitle.is("Create").first.elementClick();
      
              /* Re-select original tracks */
              sf.ui.proTools.mainWindow.invalidate();
      
              sf.ui.proTools.trackSelectByName({ names: selectedTracks });
      
              // Route selected tracks to new track
              trackOutput.popupMenuSelect({
                  isShift: true,
                  isOption: true,
                  menuPath: ["track", newTrackName + "*"],
                  useWildcards: true,
              });
      
              // Otherwise create new folder track
      
          } else {
              // Create new Folder Track
              sf.ui.proTools.menuClick({
                  menuPath: ["Track", "Move to New Folder..."],
              });
      
              const newFolderWin = sf.ui.proTools.windows.whoseTitle.is("Move To New Folder").first
      
              newFolderWin.elementWaitFor()
      
              newFolderWin.popupButtons.first.popupMenuSelect({
                  menuPath: ["Routing Folder"],
                  useWildcards: false,
              });
      
              var isChecked = newFolderWin.checkBoxes.whoseTitle.is("Route Tracks to New Folder").first.isCheckBoxChecked;
              if (!isChecked) {
                  newFolderWin.checkBoxes.whoseTitle.is("Route Tracks to New Folder").first.elementClick();
              };
              newFolderWin.textFields.whoseTitle.is("Track Name").first.elementSetTextFieldWithAreaValue({
                  value: newTrackName,
              });
              newFolderWin.popupButtons.whoseDescription.is("Track format").first.popupMenuSelect({
                  menuPath: [trackWidth]
              });
              newFolderWin.buttons.whoseTitle.is("Create").first.elementClick();
      
          };
      
          // Route newly created trackto original track output
          sf.ui.proTools.mainWindow.invalidate();
      
          sf.ui.proTools.trackSelectByName({ names: [newTrackName] });
      
      
          sf.ui.proTools.selectedTrack.groups.whoseTitle.is("Audio IO").first.
              popupButtons.whoseTitle.contains("Audio Output").first.popupMenuSelect({
                  menuPath: outputPath,
              });
      
          // Call up gropup window (if selected at start of script)
          if (makeGroup == 'Yes') {
              // Select original tracks
              sf.ui.proTools.trackSelectByName({ names: selectedTracks });
      
              // Restore floating windows
              if (areFloatingWindowsVisible) {
                  sf.ui.proTools.menuClick({
                      menuPath: ['Window', 'Hide All Floating Windows']
                  })
              };
              // open Create Group WIndow
              sf.ui.proTools.menuClick({
                  menuPath: ['Track', 'Group...']
              });
      
              sf.ui.proTools.createGroupDialog.elementWaitFor();
      
              sf.ui.proTools.createGroupDialog.textFields.first.elementSetTextFieldWithAreaValue({
                  value: groupName,
              });
      
          };
      } catch (err) {
          // If user cancels or there is an error restore floating windows
      } finally {
          if (areFloatingWindowsVisible) {
              sf.ui.proTools.menuClick({
                  menuPath: ['Window', 'Hide All Floating Windows']
              })
          };
      }
      if (selectedTracks.length == 0){log ("No Tracks Selected","")};
      
      
      
      
      1. if you already know the track type or width just replace either of the first two var declarations like this:

        var trackType = "Aux Input"
        var trackWidth = "Stereo"
        1. In reply toChris_Shaw:
          FFannar Magnusson @Fannar_Magnusson
            2021-08-27 19:15:58.666Z

            This script is.. AMAZING! Thank you so much!

            One more thing.. Would it be possible to also take the tracks I select and make a group of them which I would then be able to manually name via a pop up window like you did with the outputs and aux/folder?

            1. What parameters would you like in the group: volumes and mutes, just volume. An edit group?
              There’s a lot of options there.

              1. It would probably be easiest to select the original tracks, call up the group window, put the cursor in the group name field and let you do the rest.

                1. FFannar Magnusson @Fannar_Magnusson
                    2021-08-27 19:37:48.337Z

                    And is that something that is possible to have SoundFlow do when it's done with your script you posted here? Make it the last step in your script, grouping the tracks and then open the group window and I would do the rest manually? Sorry I'm a total noob but really interesting in the SoundFlow world and how this all works.

                    1. The script now asks if you want to create a group with the selected tracks. If the answer is yes then it'll ask for the name of the group. When the script finishes it will open the group dialog and enter the group name. You set things as you like.

                      I also changed the way the script asks for track type and width using radio buttons instead which will save you two mouse clicks over the previous version

                      //CS//

                      1. FFannar Magnusson @Fannar_Magnusson
                          2021-08-30 13:48:39.689Z

                          Jesus you are good. Thanks a lot!

                          1. Honestly, I had a script that was similar to this that I needed to update. You’re request gave me a reason to do it. 👍

              2. I've edited the code slightly to accommodate declaring the variables (var) directly.

                1. F
                  Fannar Magnusson @Fannar_Magnusson
                    2021-08-27 19:09:42.994Z

                    Wow thanks Chris! Will try this out tonight :D

                    1. Chris Shaw @Chris_Shaw2021-08-27 21:35:07.803Z2021-08-28 01:47:45.209Z

                      One last revision:
                      The script now grabs the output path of the first selected track and assigns it to the newly created Aux/Folder track.
                      It also hides any floating windows and restores them when script is finished, user cancels, or if there's an error.

                      I think all bases are covered now :)

                      1. P
                        Philip weinrobe @Philip_weinrobe
                          2021-09-22 15:23:18.135Z

                          i am loving this script. i've modified it to make all my main mix busses.
                          question: can we add one parameter to the script to make it inherit the color of the first track selected? this would be incredibly helpful

                          1. J
                            Johan Nordin @Johan_Nordin
                              2022-01-26 17:48:29.983Z

                              Hello! I really like this script - really good job @Chris_Shaw!

                              I tried to add some stuff that suited my workflow but I'm not good enough to combine the different functions I wanted.

                              The functions I tried to add was:

                              1. Copy the inserts and sends from the first selected track and in the end of the script paste it to the new aux/routing folder
                              2. After copying the inserts and sends from the first track, clear/remove them from all selected tracks, I only need them on the aux/routing folder

                              What do you think, is that something you would like to add? :)

                              Best, Johan Nordin

                              1. G
                                Gary Keane @Gary_Keane
                                  2023-01-24 16:35:46.590Z

                                  @Chris_Shaw That script is amazing. I'm looking for a simplified version if you can help? I'd like it to do the following:

                                  1. Set the output of the selected track(s) to a new stereo aux track (I usually select 'new track' from the output menu)
                                  2. Ask for the new Aux Track Name (As it does in Pro Tools anyway) - Example "GTRS"
                                  3. Creates the new stereo aux track called "GTRS"
                                  4. Renames the bus "GTRS"
                                  5. Creates a new group called "GTRS" but excludes the Aux track in the group.

                                  Is it possible?

                                  Basically, I normally select a group of tracks, hold shift+alt (to apply to those selected) and click on the output menu and then select 'new track...'.
                                  -Then I select a stereo aux track and rename it which automatically renames to bus also.
                                  -Then I create a group and call it the same name as the aux I just created.

                                  Trying to automate all this if that makes sense.