No internet connection
  1. Home
  2. How to

how to select multiple tracks?

By Davide Favargiotti @dieffe
    2018-08-02 09:26:12.796Z

    ok this is the script I'm trying

    var num = sf.ui.proTools.selectedTrackCount;
    var track = 'Untreated '
    for (var i =1; i-1 < num; i++){
    sf.ui.proTools.trackSelectByName({names: [track + i.toString()]});
    }
    

    I know what's wrong (the array in the for loop go through the numbered tracks one after the other), but I don't know how to fix it (should take some javascript classes, or any language probably) so that SF select all the tracks, not just the last one.

    In theory, the 'names' array should have all the name.. so probably while writing it this post I found the solution?
    let's try...

    Solved in post #3, click to view
    • 17 replies
    1. D
      Davide Favargiotti @dieffe
        2018-08-02 09:33:04.370Z

        Doh... I thought this:

        var num = sf.ui.proTools.selectedTrackCount;
        var track = 'Untreated '
        var trackName = []
        for (var i =1; i-1 < num; i++){
        trackName[i]= track + i.toString();
        }
        sf.ui.proTools.trackSelectByName({names: trackName});
        

        was the solution... but it's not. So.. I still need some help from anybody more skilled in coding :)

        1. In reply todieffe⬆:

          Hi @dieffe.
          You were close.

          Since trackSelectByName can operate once on all the names, you just need to call that function once, with an array of the names.

          To build up your array, you could do something like this:

          var num = sf.ui.proTools.selectedTrackCount;
          var track = 'Untreated ';
          var names = []; //Create an empty array
          for (var i = 1; i - 1 < num; i++) {
              names.push(track + i.toString()); //Push the new name to the end of the array
          }
          
          sf.ui.proTools.trackSelectByName({
              names: names, //Now pass the array to the action
              deselectOthers: true,
          });
          
          ReplySolution
          1. ?@anon6770933309
              2018-08-03 10:22:39.933Z

              May I ask, how is this supposed to work?

              1. DDavide Favargiotti @dieffe
                  2018-08-03 12:47:49.068Z

                  select multiple tracks, and the script selects the same number of tracks with specific names. (in this case untreated 1, untreated 2 etc)

                  I can use this script e.g. to copy material from some tracks to specific tracks (e.g. untreated)

                  Hope this makes sense.

                  1. ?@anon6770933309
                      2018-08-03 13:27:05.413Z

                      Thx for the clarification, Davide.
                      I tried it with tracks named "Untreated Audio 1", "Untreated Audio 2" etc. and it did not work. I tried it now with tracks named "Untreated 1", "Untreated 2" and didn't work either. It selects track "Untreated 1" only.
                      Is upper/lower case an issue?

                      1. DDavide Favargiotti @dieffe
                          2018-08-03 14:01:06.238Z

                          Seems to work just fine in my system, with different naming schemes. You have to use the script from Christian, obviously, that's the one that works! :)

                          1. ?@anon6770933309
                              2018-08-03 14:03:29.462Z

                              Yep, I used Christian's, that won't work over here. Pro Tools Ultimate 2018.7, macOS 10.13.6.

                              1. DDavide Favargiotti @dieffe
                                  2018-08-03 14:11:28.827Z

                                  Did you add any track to your session? maybe try adding invalidate command at the beginning of the script?

                                  sf.ui.proTools.mainWindow.invalidate();
                                  1. ?@anon6770933309
                                      2018-08-03 14:23:00.248Z

                                      I am trying to run the exact code Christian has posted with nothing before or afterwards yet.

                                      1. The suggestion to use invalidate actually would be my first trouble shooting step as well.

                                        1. ?@anon6770933309
                                            2018-08-03 16:02:30.447Z

                                            AFAIK invalidate is the same as stop all running commands and restarting SF which I did.
                                            But I tried what you suggested and added

                                            sf.ui.proTools.mainWindow.invalidate();
                                            

                                            And guess what? Its still not working.

                                            1. @Oli_Em can you give more details then? Steps before, which tracks do you select prior, what do you expect to happen, what happens - regular bug report steps? It works flawlessly here.
                                              Please remember, that what Davide is doing here is selecting the number of "Untreated " tracks that he has already selected. So if you've only one track selected, it will only select "Untreated 1". That was part of his intention with the script.

                                              1. ?@anon6770933309
                                                  2018-08-03 16:17:42.507Z

                                                  I am probably not getting the sense of this script, mea culpa.
                                                  "selecting the number of "Untreated " tracks that he has already selected." makes zero to none sense to me. 😜 Maybe I need a manual. Never mind Christian, its not that important to me.

                                                  1. Haha you definitely need a manual! We all do.. Can't wait to hire that assistant to write it for me... haha.
                                                    Well Davide's workflow is as far as I can tell related to dialogue (and could be for sound effects too)
                                                    When you have some clips on lets say 3 adjacent tracks and you want to copy/paste or cut/paste those into new tracks, then for the paste operation you have to select the same number of tracks as you were copy/cutting from.
                                                    So if let's say you're copying clips from your 3 Boom tracks (Boom1 Boom2 Boom3) and you want that to go to the "Untreated *" tracks. But the script doesn't know if you selected 3 boom tracks or 5 or just 1. This script uses the selectedTrackCount to know how many tracks are selected.
                                                    And then it selects the same number of "Untreated *" tracks, so it's ready to paste.

                                                    At least that's what I think he's doing ;) Davide feel free to elaborate. And frankly, if you don't mind I think you're developing a workflow that would be ideally best explained in a video. Would be wonderful if you'd have the time to share at one point!

                                                    1. DDavide Favargiotti @dieffe
                                                        2018-08-03 16:27:16.594Z

                                                        Yep, Christian, that's exactly what I'm doing.
                                                        I also added a check so the script will notify me if it tries to copy something but there are already some regions in the destination tracks.
                                                        it's such a time saver, at least for me.

                                                        I'll try to record a video during the weekend, if I have some time!

                                                        1. Wow @dieffe. Very very interested in that last part, where you're checking what's in the destination tracks!
                                                          I've wanted that for my own workflow for so long. Would you like to share your whole script in another post?

                                                          1. Oh and didn't see you were ready for a video. That would be SO great. Don't mind about quality or anything. In my dream scenario, over the next few months we all from the beta group do some video recordings, to make it a little easier accessible to people why SF rocks ;)
                                                            I definitely need to do some as well.