No internet connection
  1. Home
  2. How to

Processing to all selected sessions

By Anthony Bauman @Anthony_Bauman
    2022-05-21 11:07:53.660Z

    I have been trying to create a script that goes through each selected session, opens it, does an Izotope process, closes session, opens next session and repeats.
    The way I had been doing it was making an alias folder and creating an alias for each session I want it to work on.
    This script does not always execute correctly, and I would be very appreciative if somebody would like to share a script that works for them, or improve the script I have attached. @Andrew_Scheps It would be awesome if Bounce Factory would have an option to do this!

    function main() {
        sf.ui.finder.appActivate();
        sf.ui.finder.mainWindow.invalidate();
        sf.ui.invalidate();
    
        // Filter selected finder paths for Pro Tools Sessions
        // const selectedProToolsSessionPaths = sf.ui.finder.selectedPaths.filter(path => path.endsWith(".ptx"));
        const selectedProToolsSessionPaths = sf.ui.finder.selectedPaths.filter(path => path);
    
        // Bail out if no Pro Tools sessions are selected
        if (selectedProToolsSessionPaths.length <= 0) {
            alert(`No Pro Tools sessions were selected. Please select Pro Tools session(s) in the the finder and try again`);
            throw 0
        }
        
        // do stuff to each session
        
            // Run for each selected Session path in Finder
            selectedProToolsSessionPaths.forEach(sessionPath => {
                // Open protools session
                sf.file.open({
                    path: sessionPath,
                    applicationPath: "/Applications/Pro Tools.app",
                });
    
                // Wait for ProTools
                function waitForPtSession() {
                    sf.wait({ intervalMs: 500 })
                    while (!sf.ui.proTools.getMenuItem('File', 'Create New...').isEnabled) {
                        sf.wait({ intervalMs: 100 });
                    }
                    while (!sf.ui.proTools.invalidate().hasValidUI) {
                        sf.wait({ intervalMs: 200 })
                    }
                }
                //was having issues when opening sometimes. this is a temporary fix...I didn't know how else to make it work
                sf.wait({ intervalMs: 10000 })
                
    
                    //Insert session commands here
                    ///////////////////////////////
                    //Izotope processing here
    
    
    
                    
                sf.ui.proTools.menuClick({
                    menuPath: ["File","Save"],
                });
    
                sf.ui.proTools.menuClick({
                    menuPath: ["File","Close Session"],
                });
    
                //temporary fix to make sure session is completely closed
                sf.wait({
                    intervalMs: 10000,
                });
    
            
    
                
            });
    
            sf.ui.finder.appActivateMainWindow();
            
    sf.interaction.displayDialog({
        title: "AP Machine",
        prompt: "Machine has finished the job and is now on coffee break.",
    });
    
    }
    
    
    
    
    main();
    
    • 2 replies
    1. Andrew Scheps @Andrew_Scheps
        2022-05-23 10:54:58.643Z

        Hi Anthony,

        There could be a version of BF that does processing other than bouncing in the future.

        As you've seen opening and closing sessions is finicky and problematic, I have hundreds of lines of code that just does that and I can't really share it all.

        You're definitely on the right track though.

        1. Anthony Bauman @Anthony_Bauman
            2022-05-23 11:04:40.120Z

            Thanks for commenting. That would be really cool if you release something like that in the future!
            I know that it's greatly involving to make it robust, so I'd definitely subscribe to that on it's release day :)