No internet connection
  1. Home
  2. How to

Apply "Clip Do For Each Selected Clip" on clips within different tracks

By alex alcanjim @alex_alcanjim
    2024-02-13 14:00:15.785Z

    Hi all!

    I'm just working around some scripts using "ClipDoForEachSelectedClip". The thing is that I would need to make it work when "selected clips" come from different tracks (you can find and example in the following screenshot)

    Here comes the script I'm using now, but It only works if all selected clips are in the same track.

    sf.ui.proTools.appActivateMainWindow();
    
    function duplicate() {
        //Calling command "Open, Render and Close AudioSuite Plugin" from package "undefined" (installed from user/pkg/version "srAasovvDiQacRZ2mcId4RrOA8R2/ckp49i4j60000a2100yfwywgf/cln0nxiji0000yp102352fxp9")
        sf.soundflow.runCommand({
            commandId: 'user:ckp49i4j60000a2100yfwywgf:ckoo6b1uu000myj10s1rc02md',
            props: {
                category: "Other",
                pluginName: "Duplicate",
            }
        });
    }
    
    sf.ui.proTools.clipDoForEachSelectedClip({action:duplicate});
    

    Thanks so much in advance for your help!

    • 2 replies
    1. Nathan Salefski @nathansalefski
        2024-02-13 19:09:45.687Z2024-02-13 19:16:09.222Z

        So long as you have the 'Link Track and Edit Selection' enabled, you can try something like this:

        function duplicate() {
            // Put Stuff Here
        }
        
        function main() {
            sf.ui.proTools.appActivateMainWindow();
            sf.ui.proTools.mainWindow.invalidate();
        
            let selectedTracks = sf.ui.proTools.selectedTrackNames;
        
            selectedTracks.forEach(track => {
                sf.ui.proTools.trackSelectByName({
                    names: [track],
                    deselectOthers: true,
                });
        
                sf.ui.proTools.selectedTrack.trackScrollToView();
        
                sf.ui.proTools.clipDoForEachSelectedClip({ action: duplicate });
            });
        }
        
        main();
        
        1. Aalex alcanjim @alex_alcanjim
            2024-02-14 08:26:42.582Z

            Wow!

            It works perfectly! Thanks so much for this!

            Cheers!