No internet connection
  1. Home
  2. How to

How to automate "Move to folder"

By Sebastian @Sebastian
    2020-04-20 14:20:37.981Z
    Hi, is there a macro for the new "Move to folder..." function?
    Solved in post #2, click to view
    • 39 replies

    There are 39 replies. Estimated reading time: 25 minutes

    1. Hi Sebastian.
      Thank you for taking this to the forum :)

      You can open the Move to New Folder dialog like this:

      sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({
          isRightClick: true,
          menuPath: ['Move to...', 'New Folder...']
      });
      
      Reply1 LikeSolution
      1. SSebastian @Sebastian
          2020-04-20 14:53:16.136Z

          thanks. But there is no Macro for doing this at the moment, right?

          1. SSebastian @Sebastian
              2020-04-20 14:56:02.113Z

              sorry just realised that changing the last value is just what I need. Thanks.

              1. Great :) Yes exactly - even if you aren't familiar with scripts, often you can get what you want just by copy/pasting and changing a few things.

                1. SSebastian @Sebastian
                    2020-04-20 15:31:44.353Z

                    Sorry one more thing. I tried it the first time and it worked fine. Now I tried to copy it again but now it says there is an error in the first line. I see that in my script the popupmenuSelecte is not red anymore. Any idea how to fi it?

                    1. We'll need to see the actual error. To get the error, either:

                      • Click SF icon, where there's a small blue dot, click the grey dot to the right of it
                      • Select "Open Log File"
                      • Run your code again and copy/paste the full error in here.

                      Or - perhaps more easily - click this link and follow the instructions:
                      Please click here to send us the information we need

                      1. SSebastian @Sebastian
                          2020-04-20 16:43:21.030Z2020-04-20 16:44:09.180Z

                          Your script is working again I think it came because I tried to combine two scripts. Here is the error code and the script I tried to add to yours. I guess its a problem how I combined the two, is it?

                          20.04.2020 18:40:14.91 [Backend]: Error in line 1:
                          Could not open popup menu (PopupMenuSelectAction)
                          Popup menu was not found (OpenPopupMenuFromElementAction)
                          Popup window was not found after waiting 2000 ms (WaitForPopupMenuAction)

                          << Command: Drums [user:ck8isagfr0004mr10asts9q2y:ck98onvxf0000pg101rglaj4b]

                          sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({
                              isRightClick: true,
                              menuPath: ['Move to...', 'Drums']
                          });
                          sf.ui.proTools.selectedTrack.trackOutputSelect({
                              outputPath: ["bus","bus menu 129-256","Drums (Stereo)"],
                              selectForAllSelectedTracks: true,
                          });
                          
                          1. SSebastian @Sebastian
                              2020-04-20 16:51:07.118Z

                              I am not sure if that helps but it seems to work if I swith the two scripts.

                  • In reply tochrscheuer:
                    NNacho @Nacho_Sotelo
                      2020-04-20 18:19:18.280Z

                      And how can we apply this to all selected tracks?

                      1. This should do it:

                        sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({
                            isRightClick: true,
                            isOption: true,
                            isShift: true,
                            menuPath: ['Move to...', 'New Folder...']
                        });
                        
                        1. NNacho @Nacho_Sotelo
                            2020-04-20 18:25:40.166Z

                            Thank you!

                          • In reply toNacho_Sotelo:
                            NNacho @Nacho_Sotelo
                              2020-04-20 18:21:59.376Z

                              Right now I'm just doing it llike this

                              sf.keyboard.modifiers({
                                  isOption: true,
                                  isShift: true,
                              });
                              
                              sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({
                                  isRightClick: true,
                                  menuPath: ['Move to...', 'BVs All']
                              });
                              

                              Is there a better way?

                            • In reply tochrscheuer:

                              Hello Chritian,
                              I tried both this script and the one you posted below, to create a new folder from selected tracks and I'm getting this error.
                              Thanks for your help

                              05.06.2020 14:47:28.90 [Backend]: Error in line 1:
                              Could not open popup menu (PopupMenuSelectAction)
                              Popup menu was not found (OpenPopupMenuFromElementAction)
                              Popup window was not found after waiting 2000 ms (WaitForPopupMenuAction)

                              << Command: Move To New Folder [user:default:ckb2orp0r0000aj10nj3o9t9m]

                              1. Hi Andre.

                                My best bet would be: try to make sure that the first selected track is visible on screen and see if it helps.

                              2. In reply tochrscheuer:
                                Jjunegate @junegate
                                  2021-01-19 12:35:13.646Z

                                  Hi, I don't know how to "move to..." my selected tracks to, for example, "ITB MixBuss" folder or ">AC" subfolder

                                  I've tried but only "New Folder..." and "Top Level" works. I'm doing something wrong

                                  1. Hi @junegate

                                    Most likely those menu items start with a space (or maybe even 2 spaces). At least it looks that way visually.

                                    Can you quote the exact script you tried?

                                    1. Jjunegate @junegate
                                        2021-01-20 10:08:48.822Z

                                        Like my other issue with input and output menu list, also this script works random
                                        Let's keep it simple. I just create one routing folder called "UNO"

                                        this is the script
                                        sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({ menuPath: ['Move to...','UNO'], isRightClick: true, });
                                        the log is:

                                        PopupMenuSelectAction: Could not open popup menu
                                        !! Command Error: move to folder [user:default:ckk499pw50000tu10ou643fn8]:
                                        Could not open popup menu (move to folder: Line 1)
                                        Popup menu was not found
                                        Popup window was not found after waiting 2000 ms

                                        << Command: move to folder [user:default:ckk499pw50000tu10ou643fn8]

                                        Sometimes it works, sometimes it doesn't

                                        1. Jjunegate @junegate
                                            2021-01-20 10:22:31.246Z

                                            Maybe I found the issue.
                                            Searching on the forum i've found your advise to use
                                            sf.ui.proTools.mainWindow.invalidate();
                                            before the script

                                            I tried and now it works again. Than also the input search menu and the output search menu works again. So the problem is with the SF cache? How can i prevent this?
                                            Thanks

                                            1. You already found the solution :) If the issue is cache related, using that line of code to update the cache is the way to solve it.

                                      • In reply tochrscheuer:
                                        MMichael Hartung @Michael_Hartung
                                          2022-04-30 10:10:51.914Z

                                          Hi Christian,
                                          Can you confirm that this script works for a track that is nested inside a folder? I have been trying to make a script that takes a nested track and moves it up to the Top Level. I tried with the script you posted as the solution by changing the "New Folder..." text to say "Top Level" and it fails. Seems like a simple script, but can't seem to make it go. I'll keep looking for the answer though.

                                        • S
                                          In reply toSebastian:
                                          Sebastian @Sebastian
                                            2020-04-22 09:32:44.524Z

                                            Is there a script to move the tracks that went into a specific folder always go to the top of that folder? When there are already tracks in a folder the new ones default to go under the last one.

                                            1. We should look at reordering tracks as a separate issue (because it's a long and quite complicated topic) that is independent of the task of moving something into a folder. We do have some scripts for this that work more or less - if you start a new topic I'll link you to them in that.

                                            2. In reply toSebastian:
                                              Andrew Scheps @Andrew_Scheps
                                                2020-06-13 00:27:59.628Z

                                                This script is a bit of a mess, but here's one I made to assign selected tracks to a new routing folder. One important thing is to change the constant defined at the beginning of the scrip to the name of whatever your default output is set to (just the name of the buss, not the full menu path). Read on to find out why. Step by step, here's what it does:

                                                1. Asks you for the name of a new routing folder
                                                2. Checks to see what output the top-most selected track is assigned to
                                                3. Takes all selected tracks and puts them in a Routing folder (with your name)
                                                4. If the original output assignment was different from your default it will reassign the output of the new folder to whatever that was to preserver the signal path (unless it's hardware)
                                                
                                                // 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;
                                                
                                                // 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;
                                                
                                                sf.ui.proTools.appActivateMainWindow();
                                                // Refresh PTs track list
                                                sf.ui.proTools.mainWindow.invalidate();
                                                
                                                
                                                // Open Move to New Folder dialog and set parameters
                                                sf.ui.proTools.menuClick({
                                                    menuPath: ["Track", "Move to New Folder..."],
                                                });
                                                
                                                //Wait for the 'Move to New Folder' dialog to appear and assign it to the folderDlg variable
                                                var folderDlg = sf.ui.proTools.dialogWaitForManual({
                                                    dialogTitle: 'Move To New Folder'
                                                }).dialog;
                                                
                                                
                                                //Get the Children of the Move to New Folder dialog, filter them so we only get the popup buttons,
                                                
                                                var popupButtons = folderDlg.getElements("AXChildren").filter(function (e) { return e.fullRole == "AXPopUpButton" });
                                                
                                                //Assign the buttons coming out of the previous instruction to individual variables
                                                var folderType = popupButtons[0];
                                                
                                                if (folderType.value.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 Buss") {
                                                    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");
                                                    });
                                                }
                                                
                                                1. Thanks for this.

                                                  1. In reply toAndrew_Scheps:
                                                    GGiuliano Sulzberger @Giuliano_Sulzberger
                                                      2021-09-19 14:47:00.491Z2021-09-19 14:53:52.924Z

                                                      Hello! This is really good. Altough at the end it does not remap the outputs to the previous destination. It did it once and then never again wich adds further to my confusion..
                                                      the problem is this: I'd like to route two snare tracks in to a Routing Folder. The Snare Tracks before were routed into an "Kit 1" Aux. Wich is not assigned to a hardware output.
                                                      Output is just called "Main Out" it will just route to that one no matter what. I guess its a little thing but i cant figure it out.
                                                      There is maybe one other clue: If the first track (of the ones i want to move to the folder) is a mono track panned to the middle, the Folder Track's Left Pan will be in the middle also. The Right panpot stays untouched. I guess its trying to maintain the wrong attribute? pan instead of output routing?
                                                      Sorry for my noobish question! Any Help would be greatly appreciated!

                                                      giuli

                                                      1. In reply toAndrew_Scheps:
                                                        CCooper Babbes @cooper
                                                          2022-02-26 05:56:59.452Z

                                                          Thanks for this killer script Andrew. Is it not possible to route the new folder's output to the main hardware outs if that was the first selected track's output? That part of the script kind of stumped me; isn't it just an output name that it's storing and recalling? Can't figure out why hardware outs would cause a problem.

                                                          Also, you mentioned we should change a constant at the beginning of the script to the name of our default output. I don't see a constant like that, and it seems like the script is working anyway. Am I missing something?

                                                          1. Andrew Scheps @Andrew_Scheps
                                                              2022-02-26 15:05:27.490Z

                                                              Hi @cooper ,

                                                              Here's a version that will do hardware outputs as well. I only did that because in my case nothing ever gets routed directly to hardware, so if my source tracks are going to hardware I want to re-route the folder to my default buss. The reference to the default output above was for a different script.

                                                              // 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;
                                                              
                                                              // 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;
                                                              
                                                              sf.ui.proTools.appActivateMainWindow();
                                                              // Refresh PTs track list
                                                              sf.ui.proTools.mainWindow.invalidate();
                                                              
                                                              
                                                              // Open Move to New Folder dialog and set parameters
                                                              sf.ui.proTools.menuClick({
                                                                  menuPath: ["Track", "Move to New Folder..."],
                                                              });
                                                              
                                                              //Wait for the 'Move to New Folder' dialog to appear and assign it to the folderDlg variable
                                                              var folderDlg = sf.ui.proTools.dialogWaitForManual({
                                                                  dialogTitle: 'Move To New Folder'
                                                              }).dialog;
                                                              
                                                              
                                                              //Get the Children of the Move to New Folder dialog, filter them so we only get the popup buttons,
                                                              
                                                              var popupButtons = folderDlg.getElements("AXChildren").filter(function (e) { return e.fullRole == "AXPopUpButton" });
                                                              
                                                              //Assign the buttons coming out of the previous instruction to individual variables
                                                              var folderType = popupButtons[0];
                                                              
                                                              if (folderType.value.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
                                                              if (originalOutput !== "Mix Buss") {
                                                                  sf.ui.proTools.selectedTrack.trackOutputSelect({
                                                                      outputSelector: items => items.filter(item => item.path.slice(-1)[0].includes(originalOutput))[0],
                                                                      selectForAllSelectedTracks: true,
                                                                  });
                                                              }
                                                              
                                                              1. CCooper Babbes @cooper
                                                                  2022-02-28 19:05:08.341Z

                                                                  Ahh got it. This works beautifully, thanks a ton for taking the time to modify that!

                                                                  1. In reply toAndrew_Scheps:
                                                                    TThomas Gloor @Thomas_Gloor
                                                                      2022-04-16 17:22:19.723Z

                                                                      Hey @Andrew_Scheps !

                                                                      Thank you for this great piece of script!
                                                                      One question, though. Do you know a way of story not only the originalOutput but also the group assignment of the first selected track to then apply it to the folder, and then clear it from the original first selected track?

                                                                      That would be of great help!

                                                                      Best,

                                                                      T.

                                                                      1. Andrew Scheps @Andrew_Scheps
                                                                          2022-04-16 17:23:55.590Z

                                                                          Hi Thomas, that can be done but it's actually really complicated and not something I have time to do at the moment. Maybe somebody else will chime in!

                                                                          1. TThomas Gloor @Thomas_Gloor
                                                                              2022-04-16 17:25:00.659Z

                                                                              Hey Andrew!

                                                                              Thank you for answering! I understand. Thank you anyway :)

                                                                              1. In reply toAndrew_Scheps:
                                                                                TThomas Gloor @Thomas_Gloor
                                                                                  2022-04-19 07:32:21.577Z

                                                                                  Hey Andrew,

                                                                                  I'm trying out your script, but for some weird reason it fails at the point of switching from basic folder to routing folder in the create new folder window.

                                                                                  Any input?

                                                                                  Best

                                                                                  T

                                                                                  1. TThomas Gloor @Thomas_Gloor
                                                                                      2022-04-19 07:53:32.614Z

                                                                                      EDIT: For some reason it worked in another session!

                                                                                      1. Andrew Scheps @Andrew_Scheps
                                                                                          2022-04-19 09:22:54.035Z

                                                                                          Let me know if you can find anything reproducible. Thanks!

                                                                                          1. TThomas Gloor @Thomas_Gloor
                                                                                              2022-04-19 09:27:01.075Z

                                                                                              Will do!

                                                                                              I'm still trying to find a way to copy the orignal insert/sends/groups assignments from original track and apply them to the newly created folder.
                                                                                              I found a way using track presets (very much inspired by @Chris_Shaw's "Track Data Utility" package.

                                                                                              Basically I have a track preset named "InsSndGrp" and another "NoInsSndGrp".
                                                                                              I store the data in the first one, then recall it on the Folder.
                                                                                              I then use the second one to clear the inserts and sends but unfortunately it doesn't clear the group assignments. Bummer.

                                                                                              1. In reply toAndrew_Scheps:
                                                                                                TThomas Gloor @Thomas_Gloor
                                                                                                  2022-04-22 10:30:40.936Z

                                                                                                  Hi @Andrew_Scheps !

                                                                                                  I'm fiddling with the script for it to be able to deal with the group issue. I found a way, not super elegant, and I'm afraid, only viable for PAIRS of tracks, but it's doing what I expect it to do. Will have time to finish it later and will post it!

                                                                                                  I'm currently trying one thing but for the life of me can't achieve it. I'd like to replace the text field "Name folder" by having the script storing the first selected tracks name in a variable and then recall it with the suffix LR after. I'll post this version when I finally manage to make it work!

                                                                                                  Thank you for a great script!

                                                                                  2. O
                                                                                    In reply toSebastian:
                                                                                    Orlando Ferrer @Orlando_Ferrer
                                                                                      2020-10-29 14:56:05.308Z

                                                                                      Hello!

                                                                                      I am having intermittent issues with Andrew's script. Sometimes it works, sometimes it doesn't. When having issues it's always on line 33. I can't seem to decipher the issue... any help would be much appreciated...

                                                                                      Thanks!

                                                                                      1. Hi Orlando,

                                                                                        Please open a new thread for this and link to this thread, as this is already marked solved :) That helps us keep track of open issues and makes it easier to not forget to help. We used the "solved/solution" mark to direct resources.

                                                                                        Even better than that - and to provide even more information that will allow Andrew or others to help you - you may want to use the Script Help solution. See here how to do it (step 1):

                                                                                        1. OOrlando Ferrer @Orlando_Ferrer
                                                                                            2020-10-29 15:37:09.825Z

                                                                                            Understood! thank you, Christian