No internet connection
  1. Home
  2. How to

Move unmuted clips from selection to different tracks

By Fernando J. Alanis @Fernando_J_Alanis
    2020-12-16 22:05:37.353Z

    Hi all! I'm not sure if this has been asked before, but here goes :)

    I want to move the unmuted clips in a certain selection from RAW TAKE tracks (8 blue tracks ) to the SEL tracks (4 yellow tracks). What I do is I just move the clips to those tracks one by one, and if it overlaps then move it to the next SEL track. Is this possible? (See attached picture).

    Thanks in advance!

    Solved in post #2, click to view
    • 2 replies
    1. samuel henriques @samuel_henriques
        2020-12-17 15:16:50.312Z

        Hello @Fernando_J_Alanis ,

        this is an adaptation of Christian's script from here, https://forum.soundflow.org/-1551#post-2

        Select the every every clip on every track you want to move to the "SEL" tracks.
        Hope it works for you.

        sf.ui.proTools.appActivate();
        
        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 filterUnmutedClips() {
        
            let isMuted = sf.ui.proTools.selectionGetInfo().isClipMuted
        
            if (isMuted == false) {
                moveToTracks([
                    '1 SEL',
                    '2 SEL',
                    '3 SEL',
                    '4 SEL'
                ]);
            }
        }
        
        
        
        function main() {
            sf.ui.proTools.appActivateMainWindow();
            sf.ui.proTools.invalidate();
            const originalCounter = sf.ui.proTools.mainWindow.groups.whoseTitle.is('Counter Display Cluster').first.buttons.first.popupMenuFetchAllItems().menuItems.filter(x => x.element.isMenuChecked)[0].path.join();
            sf.ui.proTools.appActivateMainWindow()
            //Get selected tracks
            const originalTracks = sf.ui.proTools.selectedTrackNames;
        
            //Scroll first selected track to into view
            sf.ui.proTools.selectedTrack.trackScrollToView();
        
            //Do for each track.
            sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => {
        
                //Select track
                track.trackSelect();
        
                //Scroll track into View
                track.trackScrollToView();
        
                //Run Clip function
                sf.ui.proTools.clipDoForEachSelectedClip({
                    action: filterUnmutedClips,
                    onError: "Continue",
                });
        
            });
        
            //Restore previously selected tracks
            sf.ui.proTools.trackSelectByName({ names: originalTracks });
        
            sf.ui.proTools.mainWindow.groups.whoseTitle.is('Counter Display Cluster').first.buttons.first.popupMenuSelect({
                menuPath: [originalCounter],
            });
        }
        
        main()
        
        Reply1 LikeSolution
        1. Thanks a lot Samuel!! It works perfectly! :)