No internet connection
  1. Home
  2. How to

Move clip to specified track - if partial or full overwrite move to next track

By Houston Snyder @Houston_Snyder
    2020-02-14 17:49:10.736Z

    Hey everyone!

    I'm trying to create a macro that will help when organizing an AAF/OMF that productions sends from edit.

    A lot of times DX/FX/Music are scattered all over a bunch of tracks in a raw AAF. We spend a lot of time manually clicking on a SFX clip and then dragging it down to the appropriate track in our mix template. Same goes for music of dialogue.

    What I have figured our through macros is if I click on a mono sfx clip. Then Sound Flow moves it to a desired track, say "M SFX 1". Easy.

    However, if "M SFX 1" has a clip already on it in that selection, I'd like sound flow to recgonizes the conflict and instead moves it to "M SFX 2".

    If we run out of tracks maybe it throws an error or makes addition tracks.

    Same for Music and DX. Stereo/Mono.

    Let me know if anyone has any ideas. I don't really understand scripting, so i'm trying to do it all through macros. But, would love help from some one who understanding script.

    Thanks!

    Solved in post #2, click to view
    • 40 replies

    There are 40 replies. Estimated reading time: 44 minutes

    1. Hi @Houston_Snyder.

      This is a great idea.
      I've implemented something that works for me in 2019.12 here:

      
      function cutButRememberSelection() {
      
          sf.ui.proTools.mainCounterDoWithValue({
              targetValue: 'Samples',
              action: () => {
                  //Get original selection
                  var originalSelection = sf.ui.proTools.selectionGetInSamples();
      
                  var editCut = sf.ui.proTools.getMenuItem('Edit', 'Cut');
                  if (!editCut.isEnabled) throw 'No clip selected';
                  editCut.elementClick({}, 'Could not cut clip');
      
                  sf.ui.proTools.selectionSetInSamples({
                      selectionStart: originalSelection.selectionStart,
                      selectionEnd: originalSelection.selectionEnd,
                  });
              }
          });
      
      }
      
      function selectionOverlapsWithExistingClip() {
          return sf.ui.proTools.getMenuItem("Edit", "Trim Clip", "To Selection").exists;
      }
      
      function moveToTracks(trackNames) {
          var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
      
          cutButRememberSelection();
      
          var success = false;
          for (var i = 0; i < trackNames.length; i++) {
              var trackName = trackNames[i];
      
              sf.ui.proTools.trackSelectByName({
                  names: [trackName],
                  deselectOthers: true,
              });
      
              //Update menu
              sf.keyboard.press({ keys: 'cmd+shift+numpad plus,cmd+shift+numpad minus' });
              if (selectionOverlapsWithExistingClip())
                  continue;
      
              var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
              if (!editPaste.isEnabled) throw 'Cannot paste here';
              editPaste.elementClick({}, 'Could not paste clip');
              success = true;
              break;
          }
      
          sf.ui.proTools.trackSelectByName({
              names: [originalTrackName],
              deselectOthers: true,
          });
      
          if (!success) {
              sf.ui.proTools.getMenuItem('Edit', 'Undo Cut').elementClick();
          }
      }
      
      moveToTracks([
          'M SFX 1',
          'M SFX 2',
          'M SFX 3',
          'M SFX 4',
          'M SFX 5'
      ]);
      

      You change the track names it should work on in the bottom of the script.

      Reply2 LikesSolution
      1. HHouston Snyder @Houston_Snyder
          2020-02-15 14:36:01.631Z

          Christian, This is amazing. Thank you so much! Is it possible for the script to determine if the track is mono or stereo? Like if its stereo it automatically moves it to "S SFX 1" or if mono "M SFX 1"? And then implements the non-overwriting portion?

          1. In reply tochrscheuer:
            Chris Roberts @Chris_Roberts
              2020-02-16 12:47:44.822Z

              This is great, Christian!

              When I get done with the current project I'm going to have a dig into the scripting here.

              I may find a way to create some scripts I'd like to get working.

              Best

              Chris

              1. In reply tochrscheuer:
                HHouston Snyder @Houston_Snyder
                  2020-03-06 21:34:34.891Z

                  Hey there!

                  Not sure what I did, but this script isnt working in 2019.12 .

                  It cuts the clip and goes to the M SFX 1 track, but then pastes the file back on the original track.

                  Error code here:

                  06.03.2020 16:33:23.11 [Backend]: Received StreamDeck keydown: {
                  "action": "org.soundflow.streamdeck.sfcommand",
                  "context": "C46B917937EBF28A379BA82EC9F37F9A",
                  "device": "615E3364643E6A8EA80498ED0BDBA911",
                  "event": "keyDown",
                  "payload": {
                  "coordinates": {
                  "column": 0,
                  "row": 0
                  },
                  "isInMultiAction": false,
                  "settings": {
                  "isFullScreenCommand": true
                  }
                  }
                  }

                  Command: user:ck6npa06t0000hp10xd2ijrir:ck7c54i6o0000yz10lmgg9kgq
                  Sending event /commands/started with subject: ToAgent...

                  06.03.2020 16:33:23.49 [Backend]: Clicking with mouse here: 817, 72

                  06.03.2020 16:33:23.57 [Backend]: Succesfully set selection to: MainCounter: Sel Start: 4398394 Sel End: 5070138 Sel Length:

                  06.03.2020 16:33:23.61 [BackendConnection]: Received msg from backend: { name: '/commands/started', args: { r: 1, e: 93 } }
                  06.03.2020 16:33:24.04 [Backend]: << Command: user:ck6npa06t0000hp10xd2ijrir:ck7c54i6o0000yz10lmgg9kgq
                  Sending event /commands/completed with subject: ToAgent...

                  06.03.2020 16:33:24.04 [BackendConnection]: Received msg from backend: { name: '/commands/completed', args: { r: 0, e: 94 } }
                  06.03.2020 16:33:25.69 [Backend]: Firebase Subscription: Number of fast null reads exceeded. Trying to reconnect

                  06.03.2020 16:33:26.00 [Backend]: Datasub global/users/JIyOiQpC8Kfm7WHydDGGVbNB0MJ2/subscriptions upstream value changed at subpath: subscriptions to {"AzyWLaRpjj6DeP2H":{"data":{"activated_at":158352...

                  1. Hi Houston,

                    Would you be able to do a short video recording of this in action? Just to see if I can spot anything that looks different from my setup / how it works here, that could explain the difference.

                    1. HHouston Snyder @Houston_Snyder
                        2020-03-06 21:52:36.833Z

                        No problem. Here ya go!

                        Move to track small.mov (608.87 kB)

                        1. Ah great. I think you need to have Link Track and Edit Selection turned on for it to work :)

                          1. HHouston Snyder @Houston_Snyder
                              2020-03-09 15:49:34.608Z

                              Hey Christian,

                              So, that worked! It moves down to M SFX 1 and pastes. However, when I do it again, with a clip on M SFX 1, it failes with this:
                              Sending event /commands/started with subject: ToAgent...

                              09.03.2020 11:47:11.66 [BackendConnection]: Received msg from backend: { name: '/commands/started', args: { r: 1, e: 115 } }
                              09.03.2020 11:47:11.99 [Backend]: Clicking with mouse here: 773, 74

                              09.03.2020 11:47:12.07 [Backend]: Succesfully set selection to: MainCounter: Sel Start: 1277276 Sel End: 1539538 Sel Length:

                              09.03.2020 11:47:12.71 [Backend]: Javascript error with innerexception of type: null

                              09.03.2020 11:47:12.74 [BackendConnection]: Received msg from backend: { name: '/commands/completed', args: { r: 0, e: 116 } }
                              09.03.2020 11:47:12.71 [BackendConnection]: Received msg from backend: {
                              name: '/commands/error',
                              args: {
                              command: 'user:ck6npa06t0000hp10xd2ijrir:ck7c54i6o0000yz10lmgg9kgq',
                              commandName: 'Drop to Mono SFX',
                              error: 'Cannot paste here\n(Drop to Mono SFX line 46) \n'
                              }
                              }
                              09.03.2020 11:47:12.71 [Backend]: Cannot paste here
                              (Drop to Mono SFX line 46)

                              Sending event /commands/error with subject: ToAgent...
                              Sending event /log/entry with subject: ToAgent...
                              << Command: user:ck6npa06t0000hp10xd2ijrir:ck7c54i6o0000yz10lmgg9kgq
                              Sending event /commands/completed with subject: ToAgent...

                              09.03.2020 11:47:12.77 [BackendConnection]: Received msg from backend: {
                              name: '/log/entry',
                              args: {
                              entry: {
                              title: 'Drop to Mono SFX failed',
                              message: 'Cannot paste here\n(Drop to Mono SFX line 46) \n'
                              }
                              }
                              }

                              1. This error implies that Pro Tools had the "Paste" menu item disabled at the time we were wanting to click Paste.
                                Did you see it end up on M SFX 2? Can you double check after the error occurs if you then manually click the Edit menu, is the "Paste" menu item then greyed out?
                                If it is greyed out, then Pro Tools for some reason doesn't want you to paste on that track - this may be because of session setup. If it is not greyed out, then chances are that SoundFlow tried to paste too soon, before Pro Tools got a chance to update the menu item. If that's the case, then we can alter some timing logic in the script.

                                1. Note - you might have better luck by simply deleting this line:

                                  if (!editPaste.isEnabled) throw 'Cannot paste here';
                                  
                      • In reply tochrscheuer:
                        A@alex
                          2020-03-15 21:20:10.697Z

                          FYI -- The script above will overwrite a clip on a target track if the selection happens to be exactly as long as the length of the clip. To avoid that, change selectionOverlapsWithExistingClip()

                          function selectionOverlapsWithExistingClip() {
                              return sf.ui.proTools.getMenuItem("Edit", "Separate Clip", "At Transients").exists;
                          }
                          
                          1. Awesome! Thanks for that @alex.

                          2. In reply tochrscheuer:

                            This is amazing I'm having a blast using it. Often times Stereo Files come to me on two stacked monos. I've created 'stereo's only group' to send these stacked files to, and was hoping when I had 2 tracks selected it would simple copy both and paste to the single stereo track, but alas it did not work. Is this an easy additon to this script?

                            Thanks!
                            Owen Granich-Young

                          3. In reply toHouston_Snyder:

                            Manne Kjellander asked on FB if this can be done using playlists. It can.

                            This script works (all playlists need to be visible - the track needs to be in playlist view):

                            
                            function cutButRememberSelection() {
                            
                                sf.ui.proTools.mainCounterDoWithValue({
                                    targetValue: 'Samples',
                                    action: () => {
                                        //Get original selection
                                        var originalSelection = sf.ui.proTools.selectionGetInSamples();
                            
                                        var editCut = sf.ui.proTools.getMenuItem('Edit', 'Cut');
                                        if (!editCut.isEnabled) throw 'No clip selected';
                                        editCut.elementClick({}, 'Could not cut clip');
                            
                                        sf.ui.proTools.selectionSetInSamples({
                                            selectionStart: originalSelection.selectionStart,
                                            selectionEnd: originalSelection.selectionEnd,
                                        });
                                    }
                                });
                            
                            }
                            
                            function selectionOverlapsWithExistingClip() {
                                return sf.ui.proTools.getMenuItem("Edit", "Trim Clip", "To Selection").exists;
                            }
                            
                            function moveToNextFreePlaylist() {
                                var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                            
                                var trackNameRoot = originalTrackName.match(/^(.*?)(\.\d+)?$/)[1];
                                var matchingPlaylists = sf.ui.proTools.visibleTrackHeaders.filter(n => n.normalizedTrackName !== originalTrackName && n.normalizedTrackName.indexOf(trackNameRoot) === 0);
                                //log('matchingPlaylists: ' + JSON.stringify(matchingPlaylistNames.map(p => p.normalizedTrackName)));
                            
                                cutButRememberSelection();
                            
                                var success = false;
                                for (var i = 0; i < matchingPlaylists.length; i++) {
                                    //Go to next track, update menu
                                    sf.keyboard.press({ keys: 'semicolon,cmd+shift+numpad plus,cmd+shift+numpad minus' });
                                    if (selectionOverlapsWithExistingClip())
                                        continue;
                            
                                    var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
                                    if (!editPaste.isEnabled) throw 'Cannot paste here';
                                    editPaste.elementClick({}, 'Could not paste clip');
                                    success = true;
                                    break;
                                }
                            
                                sf.ui.proTools.trackSelectByName({
                                    names: [originalTrackName],
                                    deselectOthers: true,
                                });
                            
                                if (!success) {
                                    sf.ui.proTools.getMenuItem('Edit', 'Undo Cut').elementClick();
                                    sf.wait({ intervalMs: 400 });
                                    sf.keyboard.press({ keys: 'ctrl+backslash' });
                                    var win = sf.ui.proTools.windows.whoseTitle.isNullOrEmpty.first.elementWaitFor().element;
                                    win.buttons.whoseTitle.is('OK').first.elementClick();
                                    win.elementWaitFor({ waitForNoElement: true });
                                }
                            }
                            
                            moveToNextFreePlaylist();
                            
                            1. J
                              In reply toHouston_Snyder:
                              Jonathan Wales @Jonathan_Wales
                                2020-02-15 21:38:32.649Z

                                It would be amazing if we could make a variation of this so that BEFORE You hit RENDER on an Audiosuite function, it will put a safety copy of the unprocessed clip onto an underlying playlist.....

                                Is that a possible variation? If so I would add it to every function I have that does an Audiosuite Render

                                1. AAlexander Buck @Alexander_Buck
                                    2020-07-20 17:09:18.679Z

                                    Hi Christian,
                                    I tried to change the script (the first one) to copy the clips instead of cut them, and paste them to the next free track, unfortunately unsuccessful. Would you be so kind to give me a initial idea?

                                    Thanks a lot, best
                                    Aex

                                    1. Just cheat?

                                      Duplicate and make inactive the whole set of tracks you want to keep a copy of, use script as is, delete the set of tracks you cut from, leave full untouched orginal copy :)

                                      Just an idea 🤷🏽‍♂️

                                  • In reply toHouston_Snyder:
                                    Erik Griekspoor @Erik_Griekspoor
                                      2021-11-30 09:05:37.895Z

                                      This is great, but it only works for me on mono tracks, if I want to use stereo tracks it says: Cannot paste here
                                      (Move to FX dumptracks Stereo EG line 47)
                                      Any Idea how to fix this?

                                      1. I have adpated this to a template and it works on Stereo > Stereo in my AAF ORGANIZER Template in the store. (Which btw is literally just a template adapatation of this script)

                                        HOWEVER it does not move 2 mono to a stereo track which would be IDEAL. I have no clue how to program that sadly, I've simply created 'MONO' and 'STEREO' buttons for each food group.

                                        See if that works for you Erik? - (The originating track has to be a stereo as well for it to work.)

                                        There's a 2 mono > Stereo script I found on the forum as well in that package for prepping those dual mono tracks as well.

                                        bests,
                                        Owen

                                        1. Erik Griekspoor @Erik_Griekspoor
                                            2021-12-01 11:07:19.831Z

                                            Hello Owen, this works for me, great thanks! And a a great template you've made!

                                            1. Daniel Perez @daniel_perez
                                                2022-05-12 04:52:16.595Z

                                                moving pfx to there own tracks would mean i select the desired pfx out of the dx clip, hit "b", crossfade with 2 frame equal power and let the script move the clip to pfx. however, doing this halves the fades. pt only preserves fades when manually dragging with grabber.

                                                did you wrap your head around it yet?

                                                one would let soundflow check for existing crossfades, and then let soundflow do:
                                                1: check if selected clip has existing crossfade connected left/right to another clip
                                                2. if yes - extend selection of clip to include the complete crossfade
                                                3. copy clip instead of cut
                                                4. paste on target track
                                                5. go back to original selection
                                                6. reduce selection to only include clip without fades
                                                7. delete clip

                                                only then are original crossfade lengths preserved.

                                                1. Certainly well beyond my capabilities. I saw your other post and messed around for a little while out of curiosity, I see that indeed it only works if you click and drag. Your logic above makes perfect sense for an alternative way to do this, however coding that is well and good beyond me. Worth bringing up in the webinar next week perhaps and seeing if you can entice @Kitch to take a stab at it for you.

                                                  Bests,
                                                  Owen

                                                  1. In reply todaniel_perez:

                                                    Hey @daniel_perez ,

                                                    I've gotten better at coding since this, and here's the PFX dream, just highlight what you want cut out and then press your button.

                                                    function cutButRememberSelection() {
                                                    
                                                        sf.ui.proTools.mainCounterDoWithValue({
                                                            targetValue: 'Samples',
                                                            action: () => {
                                                                //Get original selection
                                                                var originalSelection = sf.ui.proTools.selectionGetInSamples();
                                                    
                                                                var editCut = sf.ui.proTools.getMenuItem('Edit', 'Cut');
                                                                if (!editCut.isEnabled) throw 'No clip selected';
                                                                editCut.elementClick({}, 'Could not cut clip');
                                                    
                                                                sf.ui.proTools.selectionSetInSamples({
                                                                    selectionStart: originalSelection.selectionStart,
                                                                    selectionEnd: originalSelection.selectionEnd,
                                                                });
                                                            }
                                                        });
                                                    
                                                    }
                                                    
                                                    function selectionOverlapsWithExistingClip() {
                                                        return sf.ui.proTools.getMenuItem("Edit", "Trim Clip", "To Selection").exists;
                                                    }
                                                    
                                                    function moveToTracks(trackNames) {
                                                        var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                                    
                                                        cutButRememberSelection();
                                                    
                                                        var success = false;
                                                        for (var i = 0; i < trackNames.length; i++) {
                                                            var trackName = trackNames[i];
                                                    
                                                            sf.ui.proTools.trackSelectByName({
                                                                names: [trackName],
                                                                deselectOthers: true,
                                                            });
                                                    
                                                            //Update menu
                                                            sf.keyboard.press({ keys: 'cmd+shift+numpad plus,cmd+shift+numpad minus' });
                                                            if (selectionOverlapsWithExistingClip())
                                                                continue;
                                                    
                                                            var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
                                                            if (!editPaste.isEnabled) throw 'Cannot paste here';
                                                            editPaste.elementClick({}, 'Could not paste clip');
                                                            success = true;
                                                            break;
                                                        }
                                                    
                                                        sf.ui.proTools.trackSelectByName({
                                                            names: [originalTrackName],
                                                            deselectOthers: false,
                                                        });
                                                    
                                                        if (!success) {
                                                            sf.ui.proTools.getMenuItem('Edit', 'Undo Cut').elementClick();
                                                        }
                                                    }
                                                    
                                                    function extendAndFade() {
                                                        /// Fill end
                                                        sf.ui.proTools.menuClick({ menuPath: ["Edit", "Trim Clip", "End to Fill Selection"] });
                                                    
                                                        /// Fill Start
                                                        sf.ui.proTools.menuClick({ menuPath: ["Edit", "Trim Clip", "Start to Fill Selection"] });
                                                    
                                                        /// Create Fade
                                                        sf.ui.proTools.menuClick({
                                                            menuPath: ["Edit", "Fades", "Create..."],
                                                        });
                                                    
                                                        /// Click Fade window ENTER
                                                        sf.ui.proTools.windows.whoseTitle.contains('Fade').first.buttons.whoseTitle.is("OK").first.elementClick();
                                                    }
                                                    
                                                    function main() {
                                                        /// Get Current Selection
                                                        const currentSelection = sf.ui.proTools.selectionGetInSamples()
                                                    
                                                        /// EDIT YOUR TRACK ARRAY HERE
                                                        moveToTracks([
                                                            'PFX 1',
                                                            'PFX 2',
                                                            'PFX 3'
                                                        ]);
                                                    
                                                        /// Set Fade Length in samples
                                                        sf.ui.proTools.selectionSetInSamples({
                                                            selectionStart: Number(currentSelection.selectionStart) - 2000,
                                                            selectionLength: 4000,
                                                        })
                                                    
                                                        extendAndFade();
                                                    
                                                        /// Set Fade Length in samples
                                                        sf.ui.proTools.selectionSetInSamples({
                                                            selectionStart: Number(currentSelection.selectionEnd) - 2000,
                                                            selectionLength: 4000,
                                                        })
                                                    
                                                        extendAndFade();
                                                    }
                                                    
                                                    main();
                                                    

                                                    LINE 83 is where you define your destination track ARRAY in this case I've made it PFX 1-3

                                                    Line 90 and Line 98 are the fade lengths for the start fade and end fade. Currently set to 2 frames in a 24-FPS session adjust as you see fit.

                                                    Bests,
                                                    Owen

                                                    ps it will still only work with 1 track at a time...

                                                    1. Daniel Perez @daniel_perez
                                                        2023-01-23 13:24:18.889Z

                                                        i will try it! let's wait what pro tools script apk will bring us for long awaited goodies. creating own UIs for plugins, rendering without opening plugins, etc. changing prefs without opening them. deeper and better wait for feedbacks.

                                                2. In reply toHouston_Snyder:
                                                  Jack Green @Jack_Green
                                                    2023-03-16 15:25:13.766Z

                                                    Did anyone ever get this working with 5.1 tracks?

                                                    Thanks !

                                                    1. In reply toHouston_Snyder:
                                                      Joe Costable @Joe_Costable
                                                        2023-06-07 19:52:54.916Z

                                                        So with the help of AI I've been playing with this and got it to duplicate the last track if there are no more, but once it duplicates, it no longer iterates through the newest track and continues. Example, if there's no 9, it makes it, but next time it needs to duplicate a track it again stops at 8 and tries to create 9.

                                                        Further work on this to make it able to distinguish between a mono and stereo track would be amazing. Here's the code

                                                        function duplicateLastMoveToTrack(trackNames) {
                                                          var lastTrackName = trackNames[trackNames.length - 1];
                                                          var lastTrackNumber = parseInt(lastTrackName.split(" ")[1]);
                                                          var duplicatedTrackNumber = lastTrackNumber + 1;
                                                          var duplicatedTrackName = "Dio " + duplicatedTrackNumber;
                                                        
                                                          var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                                        
                                                          sf.ui.proTools.trackDuplicateSelected({
                                                            duplicateActivePlaylist: false,
                                                            duplicateAlternatePlaylists: false,
                                                            duplicateAutomation: false,
                                                            duplicateGroupAssignments: true,
                                                            duplicateInserts: true,
                                                            duplicateSends: true,
                                                            insertAfterLastSelectedTrack: true,
                                                            numberOfDuplicates: 1,
                                                          });
                                                        
                                                          sf.ui.proTools.trackSelectByName({
                                                            names: [originalTrackName],
                                                            deselectOthers: false,
                                                          });
                                                        
                                                          sf.ui.proTools.selectedTrack.trackBulkRenameNumerical();
                                                        
                                                          trackNames.push(duplicatedTrackName);
                                                        }
                                                        
                                                        
                                                        1. Seems like you'd have to find a way for it to push the duplicated track into the array and keep it there. Right now the array of 'tracks to try' is a static array you'd somehow need to make that a flexible .globalstate or .json array somehow so it knows 'hey this new dupe is now a member of the 'tracks to check' sense making?

                                                          Re: telling if it's stereo or not, this piece of code might help,

                                                          const track = sf.ui.proTools.selectedTrack
                                                          const width = track.groups.whoseTitle.is('Audio IO').first.sliders.whoseTitle.contains('Pan').count;
                                                          
                                                          if (width == 1) {
                                                          
                                                              ///if mono run this code
                                                          
                                                          } else {
                                                          
                                                              //if stereo run this code
                                                          
                                                          }
                                                          

                                                          so you could do something with this that's 'look at the original track width and use the 'mono tracks to try' if its mono and 'stereo tracks to try' if it's stereo?

                                                          Maybe that's helpful? Lemme know what you come up with, would be happy to update the command template package with this.

                                                          1. Joe Costable @Joe_Costable
                                                              2023-06-07 22:43:44.667Z

                                                              Awesome Thank you- I figured as much about the “flexible” array but not sure how to implement it.
                                                              Thanks for the mono/stereo points, I think that’s the way to handle it. OR check if it’s mono or stereo, then use the mono or stereo array…

                                                              Also realizing I didn’t post the full code, so I’ll put that up tomorrow

                                                              1. Joe Costable @Joe_Costable
                                                                  2023-06-10 01:57:35.472Z

                                                                  Thank you again for the if statements, here's what I have so far-

                                                                  Moves mono track to next available mono dialogue track, moves a stereo clip to the stereo dialogue track, moves 2 mono clips to the stereo track.

                                                                  sf.ui.proTools.appActivateMainWindow();
                                                                  
                                                                  //Make sure Link Track and Edit Selection is enabled
                                                                  sf.ui.proTools.menuClick({
                                                                      menuPath: ["Options", "Link Track and Edit Selection"],
                                                                      targetValue: "Enable"
                                                                  });
                                                                  
                                                                  const track = sf.ui.proTools.selectedTrack
                                                                  const width = track.groups.whoseTitle.is('Audio IO').first.sliders.whoseTitle.contains('Pan').count;
                                                                  const originalSelectedTrackCount = sf.ui.proTools.selectedTrackCount;
                                                                  
                                                                  
                                                                  ///Set "moveToTracks" and "moveToStTracks" to the list of possible tracknames in your session
                                                                  if (width == 1 && originalSelectedTrackCount == 2) {
                                                                  
                                                                      moveToStTracks([
                                                                      'Dio Stereo',
                                                                      ]);
                                                                  
                                                                  } else if (width == 1){
                                                                     moveToTracks([
                                                                      'Dio 1',
                                                                      'Dio 2',
                                                                      'Dio 3',
                                                                      'Dio 4',
                                                                      'Dio 5',
                                                                      'Dio 6',
                                                                      'Dio 7',
                                                                      'Dio 8',
                                                                      ]);
                                                                  
                                                                  } else {
                                                                  
                                                                      moveToStTracks([
                                                                      'Dio Stereo',
                                                                      ]);
                                                                  
                                                                      
                                                                  }
                                                                  
                                                                  function cutButRememberSelection() {
                                                                  
                                                                      sf.ui.proTools.mainCounterDoWithValue({
                                                                          targetValue: 'Samples',
                                                                          action: () => {
                                                                              //Get original selection
                                                                              var originalSelection = sf.ui.proTools.selectionGetInSamples();
                                                                  
                                                                              var editCut = sf.ui.proTools.getMenuItem('Edit', 'Cut');
                                                                              if (!editCut.isEnabled) throw 'No clip selected';
                                                                              editCut.elementClick({}, 'Could not cut clip');
                                                                  
                                                                              sf.ui.proTools.selectionSetInSamples({
                                                                                  selectionStart: originalSelection.selectionStart,
                                                                                  selectionEnd: originalSelection.selectionEnd,
                                                                              });
                                                                          }
                                                                      });
                                                                  
                                                                  }
                                                                  
                                                                  function selectionOverlapsWithExistingClip() {
                                                                      return sf.ui.proTools.getMenuItem("Edit", "Trim Clip", "To Selection").exists;
                                                                  }
                                                                  
                                                                  function moveToTracks(trackNames) {
                                                                      var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                                                  
                                                                      cutButRememberSelection();
                                                                  
                                                                      var success = false;
                                                                      for (var i = 0; i < trackNames.length; i++) {
                                                                          var trackName = trackNames[i];
                                                                  
                                                                          sf.ui.proTools.trackSelectByName({
                                                                              names: [trackName],
                                                                              deselectOthers: true,
                                                                          });
                                                                  
                                                                          //Update menu
                                                                          sf.keyboard.press({ keys: 'cmd+shift+numpad plus,cmd+shift+numpad minus' });
                                                                          if (selectionOverlapsWithExistingClip())
                                                                              continue;
                                                                  
                                                                          var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
                                                                          //if (!editPaste.isEnabled) throw 'Cannot paste here';
                                                                          editPaste.elementClick({}, 'Could not paste clip');
                                                                          success = true;
                                                                          break;
                                                                      }
                                                                  
                                                                      sf.ui.proTools.trackSelectByName({
                                                                          names: [originalTrackName],
                                                                          deselectOthers: true,
                                                                      });
                                                                  
                                                                      if (!success) {
                                                                          sf.ui.proTools.getMenuItem('Edit', 'Undo Cut').elementClick();
                                                                      }
                                                                  }
                                                                  
                                                                  function moveToStTracks(trackNames) {
                                                                      var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                                                  
                                                                      cutButRememberSelection();
                                                                  
                                                                      var success = false;
                                                                      for (var i = 0; i < trackNames.length; i++) {
                                                                          var trackName = trackNames[i];
                                                                  
                                                                          sf.ui.proTools.trackSelectByName({
                                                                              names: [trackName],
                                                                              deselectOthers: true,
                                                                          });
                                                                  
                                                                          //Update menu
                                                                          sf.keyboard.press({ keys: 'cmd+shift+numpad plus,cmd+shift+numpad minus' });
                                                                          if (selectionOverlapsWithExistingClip())
                                                                              continue;
                                                                  
                                                                          var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
                                                                          //if (!editPaste.isEnabled) throw 'Cannot paste here';
                                                                          editPaste.elementClick({}, 'Could not paste clip');
                                                                          success = true;
                                                                          break;
                                                                      }
                                                                  
                                                                      sf.ui.proTools.trackSelectByName({
                                                                          names: [originalTrackName],
                                                                          deselectOthers: true,
                                                                      });
                                                                  
                                                                      if (!success) {
                                                                          sf.ui.proTools.getMenuItem('Edit', 'Undo Cut').elementClick();
                                                                      }
                                                                  }
                                                                  

                                                                  Duplicate and update the "array" might be on hold for now, it's rare that I need more than tracks already created in my template. I'd still like to add it at some point though.

                                                                  For now, I'm wondering how I can get this to work with the object selection tool? Maybe the cutButRememberSelection function needs to be modified to use a different method?

                                                                  1. Hey @Joe_Costable this script is great, I've taken it and templated it for general use in my AAF Organizer Package (giving credit obviously). | AAF Org Template Dual Array | I've also cracked multi track for both this and the regular AAF Organizer so that's cool, although you have to pick if you're gonna be in multi channel mode or 2 mono mode. @unnamed_455 Alex version 2.7 is up in the store and has some good updates. I think next evolution would just be buttons that you can assign the track arrays to on the fly instead of needing to template it. I'll dig around the forum for .json array stuff and see if I can make it happen.

                                                              2. In reply toHouston_Snyder:
                                                                Joe Costable @Joe_Costable
                                                                  2023-06-11 17:47:30.053Z

                                                                  Taking a step back, I'm trying to have this duplicate the track and paste, and know there's a new track created the next time it's run. I've gotten the array figured out for that, but now when it renames the track, it also selects the last track in the session and attempts to rename them both. Can't figure out what I'm missing on it, need some new eyes, any ideas?

                                                                  Once this is figured out, I plan to drop this into the mono/stereo logic in my last script.

                                                                  ///Track name list
                                                                  var prefix = "Dio";
                                                                  var trackNames = sf.ui.proTools.trackNames;
                                                                  var trackCount = 0;
                                                                  
                                                                  for (var i = 0; i < trackNames.length; i++) {
                                                                    var trackName = trackNames[i];
                                                                    if (trackName.startsWith(prefix)) {
                                                                      var trackNumber = parseInt(trackName.split(" ")[1]);
                                                                      if (!isNaN(trackNumber)) {
                                                                        trackCount = Math.max(trackCount, trackNumber);
                                                                      }
                                                                    }
                                                                  }
                                                                  
                                                                  // trackCount will now hold the maximum track number found in the existing track names
                                                                  
                                                                  
                                                                  function cutButRememberSelection() {
                                                                    sf.ui.proTools.mainCounterDoWithValue({
                                                                      targetValue: 'Samples',
                                                                      action: () => {
                                                                        // Get original selection
                                                                        var originalSelection = sf.ui.proTools.selectionGetInSamples();
                                                                  
                                                                        var editCut = sf.ui.proTools.getMenuItem('Edit', 'Cut');
                                                                        if (!editCut.isEnabled) throw 'No clip selected';
                                                                        editCut.elementClick({}, 'Could not cut clip');
                                                                  
                                                                        sf.ui.proTools.selectionSetInSamples({
                                                                          selectionStart: originalSelection.selectionStart,
                                                                          selectionEnd: originalSelection.selectionEnd,
                                                                        });
                                                                      }
                                                                    });
                                                                  }
                                                                  
                                                                  function selectionOverlapsWithExistingClip() {
                                                                    return sf.ui.proTools.getMenuItem("Edit", "Trim Clip", "To Selection").exists;
                                                                  }
                                                                  
                                                                  function duplicateLastMoveToTrack() {
                                                                    var lastTrackName = trackNames[trackNames.length - 1];
                                                                    var lastTrackNumber = parseInt(lastTrackName.split(" ")[1]);
                                                                    var duplicatedTrackNumber = lastTrackNumber + 1;
                                                                    var duplicatedTrackName = prefix + " " + duplicatedTrackNumber;
                                                                  
                                                                    sf.ui.proTools.trackDuplicateSelected({
                                                                      duplicateActivePlaylist: false,
                                                                      duplicateAlternatePlaylists: false,
                                                                      duplicateAutomation: false,
                                                                      duplicateGroupAssignments: true,
                                                                      duplicateInserts: true,
                                                                      duplicateSends: true,
                                                                      insertAfterLastSelectedTrack: true,
                                                                      numberOfDuplicates: 1,
                                                                    });
                                                                  
                                                                    sf.ui.proTools.trackSelectByName({
                                                                      names: [lastTrackName],
                                                                      deselectOthers: false,
                                                                    });
                                                                  
                                                                    sf.ui.proTools.selectedTrack.trackBulkRenameNumerical();
                                                                  
                                                                    trackNames.push(duplicatedTrackName);
                                                                    trackCount++; // Increment the trackCount variable
                                                                  }
                                                                  
                                                                  function continueMoveToTracks(originalTrackName, success) {
                                                                    var trackName = prefix + " " + trackCount;
                                                                  
                                                                    sf.ui.proTools.trackSelectByName({
                                                                      names: [trackName],
                                                                      deselectOthers: true,
                                                                    });
                                                                  
                                                                    var editPaste = sf.ui.proTools.getMenuItem("Edit", "Paste");
                                                                    editPaste.elementClick({}, "Could not paste clip");
                                                                    success = true;
                                                                  
                                                                    sf.ui.proTools.trackSelectByName({
                                                                      names: [originalTrackName],
                                                                      deselectOthers: true,
                                                                    });
                                                                  
                                                                    if (!success) {
                                                                      sf.ui.proTools.getMenuItem("Edit", "Undo Cut").elementClick();
                                                                    }
                                                                  }
                                                                  
                                                                  function moveToTracks() {
                                                                    var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                                                  
                                                                    cutButRememberSelection();
                                                                  
                                                                    var success = false;
                                                                    var currentTrackIndex = 0;
                                                                    while (currentTrackIndex < trackCount) {
                                                                      var trackName = prefix + " " + (currentTrackIndex + 1);
                                                                  
                                                                      sf.ui.proTools.trackSelectByName({
                                                                        names: [trackName],
                                                                        deselectOthers: true,
                                                                      });
                                                                  
                                                                      // Update menu
                                                                      sf.keyboard.press({ keys: "cmd+shift+numpad plus,cmd+shift+numpad minus" });
                                                                      if (selectionOverlapsWithExistingClip()) {
                                                                        if (currentTrackIndex === trackCount - 1) {
                                                                          duplicateLastMoveToTrack();
                                                                          currentTrackIndex = trackCount - 1; // Update the current track index
                                                                          continue;
                                                                        } else {
                                                                          currentTrackIndex++;
                                                                          continue;
                                                                        }
                                                                      }
                                                                  
                                                                      var editPaste = sf.ui.proTools.getMenuItem("Edit", "Paste");
                                                                      editPaste.elementClick({}, "Could not paste clip");
                                                                      success = true;
                                                                      currentTrackIndex++;
                                                                      break;
                                                                    }
                                                                  
                                                                    sf.ui.proTools.trackSelectByName({
                                                                      names: [originalTrackName],
                                                                      deselectOthers: true,
                                                                    });
                                                                  
                                                                    if (!success) {
                                                                      sf.ui.proTools.getMenuItem("Edit", "Undo Cut").elementClick();
                                                                    }
                                                                  }
                                                                  
                                                                  moveToTracks();
                                                                  
                                                                  
                                                                  sf.ui.proTools.mainWindow.invalidate();
                                                                  
                                                                  
                                                                  
                                                                  
                                                                  1. AAlexander Buck @Alexander_Buck
                                                                      2024-01-22 11:32:11.073Z

                                                                      Hi Joe,
                                                                      brilliant script!
                                                                      Have you already found a solution to the issue where the script, when renaming the duplicated track, also selects and wants to rename the last track in the session?

                                                                      Best,
                                                                      Alex

                                                                      1. Joe Costable @Joe_Costable
                                                                          2024-01-23 16:29:24.616Z

                                                                          Thanks Alex! I certainly could only do it with help from others in this forum.
                                                                          I haven’t done more work on this due to time, I kind of got it working enough to take a step back, but I’d love to revisit. Maybe others can figure out how to get this working smoother and share their ideas

                                                                          1. AAlexander Buck @Alexander_Buck
                                                                              2024-01-28 19:47:21.770Z

                                                                              Hi Joe,
                                                                              I can totally understand you, I too always rely on the help of the super helpful members with excellent programming skills. I hope someone comes across this script and can further develop it.
                                                                              Best regards, Alex

                                                                              1. Joe Costable @Joe_Costable
                                                                                  2024-01-28 22:02:01.908Z

                                                                                  Agreed. I found that I don’t normally need more than a few possible tracks anyway before a free spot is found- so the creation of new tracks is more about me wanting to make the script work in all possible scenarios than a necessity. I’d still love to get some input/insight on it though!

                                                                          2. U
                                                                            In reply toHouston_Snyder:
                                                                            @unnamed_455
                                                                              2023-11-03 20:53:08.667Z

                                                                              Hi all, been loving trying out SF these past few days.

                                                                              I do work in prepping sessions for Dx editors, and I think this script is nearly what I need... But I have one last question.

                                                                              Is there any conceivable way that I can select multiple clips on separate tracks and then have this script cascade them to my bank of XX tracks?? This would be a massive timesaver and would make this software worth it alone just for this functionality.

                                                                              Thanks in advance!
                                                                              Alex

                                                                              1. Hey Alex, I've not dived into updating this, I think maaabye you could do a track by track but it'd be clunky. I can recommend looking at my AAF Organizer package, in there there's a move to selected track command template that can take multiple clips. It's not 'intelligent' like this one it will just paste over something if it's there, it will however count the number of tracks and cut or copy down to your starting track and subsequent tracks below that and paste. So it might be nice in combo with the above intelligent version. The template you'll want to look at for this is called PASTE TO TRACK VARIABLE TRACK COUNT

                                                                                Hope that helps

                                                                                1. So I guess I'm wrong, I did already set this up to do multiple tracks I just haven't pushed it to the store yet. I'll do that shortly, Also working on a template of this one here Move clip to specified track - if partial or full overwrite move to next track #post-30 so that you don't need separate Stereo and Mono buttons.

                                                                                  1. U@unnamed_455
                                                                                      2023-11-04 20:36:01.350Z

                                                                                      This all sounds amazing!!

                                                                                      Thanks a bunch, gonna save me so much time, ideally I'll just go and select any Dx lines not needed with the object tool and then boom, stacks them all up to my bank of XX tracks, same me from having to spam CNTRL and clearing gaps to make it look "clean"

                                                                                      Regards,
                                                                                      Alex.

                                                                                      1. Object Tool does not work with the AAF organizer script, but it does with the PASTE to Track. Try that one out and see if it does what you want. Since you'll never need to worry about overlap if you're doing it all in one go anyways.