No internet connection
  1. Home
  2. How to

from pro tools export files window, navigate to session root bounced files folder

By samuel henriques @samuel_henriques
    2020-08-15 23:56:11.525Z2020-11-24 23:01:05.637Z

    Hello,
    using pro tools, I'm trying to produce a macro to export files from the export clips as files menu.

    I'm using this scipt to tell pro tools to navigate to the correct folder. It does go there but opens a window with the same patch on finder and interrupts the rest of the macro.

    I hope I was clear with the explanation

    thank you so much

    function navigateToInDialog(path) {
        //Get a reference to the focused window in the frontmost app:
        var win = sf.ui.frontmostApp.focusedWindow;
    
        //Open the Go to... sheet
        sf.keyboard.type({ text: '/' });
    
        //Wait for the sheet to appear
        var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
    
        //Set the value of the combo box
        sheet.comboBoxes.first.value.value = path;
    
        //Press OK
        sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
    
        //Wait for sheet to close
        win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time');
    }
    
    var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Bounced Files';
    
    if (sf.ui.frontmostApp.focusedWindow.title.value.match(/open|import/i)) {
        navigateToInDialog(folderPath);
    } else {
        sf.system.exec({ commandLine: 'open "' + folderPath + '"' });
        sf.ui.finder.appActivateMainWindow();
        sf.ui.finder.windows.first.elementRaise();
    }
    
    sf.ui.finder.appActivateMainWindow();
    sf.ui.finder.windows.first.elementRaise();
    sf.ui.finder.windows.first.windowMove({
        position: { x: 300, y: 200 },
        size: { x: 1600, y: 500 },
    });
    
    • 14 replies

    There are 14 replies. Estimated reading time: 17 minutes

    1. samuel henriques @samuel_henriques
        2020-08-17 17:22:47.701Z

        Hello,
        I managed to fix the script. I found one you did and deleted lines until I got what i needed.

        Im now stuck after this.
        I got it to create a new folder, but would like to get it on script instead of click ui.
        and then I need to paste text .
        Some how after creating new folder SF returns an error and won't continue.

        please help
        Thank you

        1. Joe Costable @Joe_Costable
            2020-11-25 03:31:08.870Z

            Any ideas here? Looking to get the exported file to the session root's bounced disk folder, instead of "Audio Files" folder, or worse, into the last session I exported from. Here's the code I'm using for the export portion...

            sf.keyboard.press({
                keys: "cmd+shift+k",
            });
            
            sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.elementWaitFor();
            
            sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.popupButtons.whoseTitle.is('WAV').first.popupMenuSelect({
                menuPath: ["WAV"],
            });
            
            sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.popupButtons.whoseTitle.is('24 Bit').first.popupMenuSelect({
                menuPath: ["24 Bit"],
            });
            
            sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.popupButtons.whoseTitle.is('48 kHz').first.popupMenuSelect({
                menuPath: ["48 kHz"],
            });
            
            sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Choose...').first.elementClick();
            
            sf.ui.proTools.windows.whoseTitle.is('Open').first.children.whoseRole.is("AXStaticText").whoseValue.is('Please choose a destination folder').first.elementWaitFor();
            
            sf.ui.proTools.windows.whoseTitle.is('Open').first.getElement('AXDefaultButton').elementClick();
            
            sf.ui.proTools.windows.whoseTitle.is('Open').first.elementWaitFor({waitType: "Disappear",});
            
            sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Export...').first.elementClick();
            1. samuel henriques @samuel_henriques
                2020-11-25 10:10:08.527Z

                hey @Joe_Costable,
                This is the script I'm using,

                sf.ui.proTools.appActivateMainWindow()
                
                sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
                    menuPath: ["Export Clips as Files..."],
                    targetValue: "Enable",
                });
                
                sf.keyboard.press({ keys: 'shift+command+k' });
                
                sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.elementWaitFor({
                    waitType: "Appear",
                });
                
                sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.elementWaitFor();
                
                
                ////set output to WAV  Interlieved 24bit 48kHz
                var exportSelectedMenu = sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.popupButtons
                //FILE TYPE
                if (!exportSelectedMenu.whoseTitle.is('WAV').exists) {
                    exportSelectedMenu.allItems[3].popupMenuSelect({
                        menuPath: ["WAV"],
                    });
                }
                
                //FORMAT
                if (!exportSelectedMenu.whoseTitle.is('Interleaved').exists) {
                    exportSelectedMenu.allItems[2].popupMenuSelect({
                        menuPath: ["Interleaved"],
                    });
                }
                
                //BIT DEPTH
                
                if (!exportSelectedMenu.whoseTitle.is('24 Bit').exists) {
                    exportSelectedMenu.allItems[1].popupMenuSelect({
                        menuPath: ["24 Bit"],
                    });
                
                //SAMPLE RATE
                }
                if (!exportSelectedMenu.whoseTitle.is('48 kHz').exists) {
                    exportSelectedMenu.first.popupMenuSelect({
                        menuPath: ["48 kHz"],
                    });
                }
                sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.radioButtons.whoseTitle.is('Prompting For Each Duplicate').first.checkboxSet({
                    targetValue: "Enable",
                });
                
                sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Choose...').first.elementClick();
                
                function navigateToInDialog(path) {
                    //Get a reference to the focused window in the frontmost app:
                    var win = sf.ui.frontmostApp.focusedWindow;
                
                    //Open the Go to... sheet
                    sf.keyboard.type({ text: '/' });
                
                    //Wait for the sheet to appear
                    var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
                
                    //Set the value of the combo box
                    sheet.comboBoxes.first.value.value = path;
                
                    //Press OK
                    sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
                
                    //Wait for sheet to close
                    win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time');
                }
                var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Bounced Files';
                
                if (sf.ui.frontmostApp.focusedWindow.title.value.match(/open|import/i)) {
                    navigateToInDialog(folderPath);
                } else {
                    sf.system.exec({ commandLine: 'open "' + folderPath + '"' });
                    sf.ui.finder.appActivateMainWindow();
                    sf.ui.finder.windows.first.elementRaise();
                }
                
                sf.ui.proTools.windows.whoseTitle.is('Open').first.getElement('AXDefaultButton').elementClick();
                
                sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Export...').first.elementClick();
                

                hope it helps!

                This was on Support, I moved it to How To.

                1. Joe Costable @Joe_Costable
                    2020-11-25 14:58:46.939Z

                    Ahh That's it! Thank you!

                    For whoever it helps- I have this running after recording and renaming the clip, so it's already selected, and I don't usually have the clip list open; so I just took out lines 3-6:

                    sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
                        menuPath: ["Export Clips as Files..."],
                        targetValue: "Enable",
                    });
                    
                    1. OOren Hadar @Oren_Hadar
                        2021-01-09 01:02:42.419Z

                        Thank you for this very helpful script! I'm wondering if by chance you could help me with a couple questions:

                        Is there a way to detect first if the "Bounced Files" directory exists, and if not, create it? I ask because I tend to use a folder with a different name to output my mixes.

                        Also, is there a way to detect if the exports are already routed to the correct folder, and if so, skip the step of "Choose..."ing the folder?

                        1. samuel henriques @samuel_henriques
                            2021-01-09 11:46:51.868Z2021-01-09 11:58:08.644Z

                            hello @Oren_Hadar ,
                            Happy this script is helping you.

                            try replacing,

                            var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Bounced Files';
                            

                            with this

                            var sessionPath = sf.ui.proTools.mainWindow.invalidate().sessionPath;
                            var sessionDir = sessionPath.split('/').slice(0, -1).join('/');
                            var sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
                            var mixesDir = `${sessionDir}/Bounced Files/${sessionName}_MIXES AND STEMS`;
                            
                            //Make sure the mixes directory exists
                            sf.file.directoryCreate({
                                path: mixesDir,
                            });
                            

                            then replace

                            navigateToInDialog(folderPath);
                            

                            with

                            navigateToInDialog(mixesDir);
                            

                            and replace,

                            sf.system.exec({ commandLine: 'open "' + folderPath + '"' });
                            

                            with,

                            sf.system.exec({ commandLine: 'open "' + mixesDir) + '"' });
                            

                            then you must choose a directory location and name so edit this line:

                            var mixesDir = `${sessionDir}/Bounced Files/${sessionName}_MIXES AND STEMS`;
                            

                            this line is creating a folder called "Session name" + "_MIXES AND STEMS" inside the "Bounced Files" folder.

                            let me know if you get stuck.

                            all the info is from this thread, https://forum.soundflow.org/-1978

                            about avoid the "choose..."ing folder, I don't know how, but doesn't look possible/easy, for my knowledge at least.

                            have fun!

                            1. OOren Hadar @Oren_Hadar
                                2021-01-19 21:43:01.191Z

                                Samuel,

                                Thank you, that works great!

                                If anyone knows how to detect whether the correct directory is already selected, that would be very helpful!

                                Oren

                        2. Joe Costable @Joe_Costable
                            2022-09-14 20:30:47.786Z

                            Script was working fine until latest PT/MacOS update- getting hung up where it should be entering the bounced files folder path- (line 9 below throws error message) any ideas?

                            function navigateToInDialog(path) {
                                //Get a reference to the focused window in the frontmost app:
                                var win = sf.ui.frontmostApp.focusedWindow;
                            
                                //Open the Go to... sheet
                                sf.keyboard.type({ text: '/' });
                            
                                //Wait for the sheet to appear
                                var sheet = win.sheets.first.elementWaitFor({ timeout: 1000 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
                            
                                //Set the value of the combo box
                                sheet.comboBoxes.first.value.value = path;
                            
                                //Press OK
                                sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
                            
                                //Wait for sheet to close
                                win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 1000 }, '"Go to" sheet didn\'t close in time');
                            }
                            var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Bounced Files';
                            
                            1. samuel henriques @samuel_henriques
                                2022-09-14 20:43:40.556Z

                                Hello Joe,
                                Monterey is different, here's a version I think works well on both old and new. If you still have problems with this, search the forum I think Andrew made one as well ( from witch I made this one)

                                /**
                                * @param {string} path
                                */
                                function navigateToInDialog(path) {
                                    //Get a reference to the focused window in the frontmost app:
                                    const win = sf.ui.frontmostApp.focusedWindow;
                                
                                    //Open the Go to... sheet
                                    sf.keyboard.type({ text: '/' });
                                
                                    //Wait for the sheet to appear
                                    const sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
                                
                                    //Set the value of the combo box
                                    if (sheet.comboBoxes.exists) {
                                
                                        sheet.comboBoxes.first.value.value = path;
                                
                                    } else {//OSX Monterey is different
                                
                                        sheet.textFields.whoseValue.is("/").first.value.value = path;
                                
                                    };
                                
                                    //Return or press GO
                                    sf.keyboard.press({ keys: "return" });
                                
                                    //Wait for sheet to close
                                    win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time');
                                };
                                
                                1. Joe Costable @Joe_Costable
                                    2022-09-14 21:06:47.501Z

                                    Works- Thanks!

                                    1. Joe Costable @Joe_Costable
                                        2022-09-22 16:44:17.995Z

                                        Having trouble with the export defaulting to the Audio Files folder, and not navigating to the Bounced Files folder.
                                        Lines 40-46 are how I had it doing it originally before the new change for Monterey. I'm not sure where/how to have SF navigate to "folderPath"- ?

                                        
                                        
                                        sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Choose...').first.elementClick();
                                        
                                        function navigateToInDialog(path) {
                                            //Get a reference to the focused window in the frontmost app:
                                            const win = sf.ui.frontmostApp.focusedWindow;
                                        
                                            //Open the Go to... sheet
                                            sf.keyboard.type({ text: '/' });
                                        
                                            //Wait for the sheet to appear
                                            const sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
                                        
                                            //Set the value of the combo box
                                            if (sheet.comboBoxes.exists) {
                                        
                                                sheet.comboBoxes.first.value.value = path;
                                        
                                            } else {//OSX Monterey is different
                                        
                                                sheet.textFields.whoseValue.is("/").first.value.value = path;
                                        
                                            };
                                        
                                        
                                            //Return or press GO
                                            sf.keyboard.press({
                                            keys: "return",
                                        });
                                        
                                        
                                            //Wait for sheet to close
                                            win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time');
                                        };
                                        
                                        
                                        var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Bounced Files';
                                        
                                        ///if (sf.ui.frontmostApp.focusedWindow.title.value.match(/open|import/i)) {
                                        ///    navigateToInDialog(folderPath);
                                        ///} else {
                                        ///    sf.system.exec({ commandLine: 'open "' + folderPath + '"' });
                                        ///    sf.ui.finder.appActivateMainWindow();
                                        ///    sf.ui.finder.windows.first.elementRaise();
                                        ///}
                                        
                                        
                                        sf.ui.proTools.windows.whoseTitle.is("Open").first.buttons.whoseTitle.is("Open").first.elementClick();
                                        
                                        sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Export...').first.elementClick();
                                        
                                         //Return or press GO
                                            sf.keyboard.press({
                                            keys: "return",
                                        });
                                        
                                        1. samuel henriques @samuel_henriques
                                            2022-09-22 17:12:37.523Z2022-09-22 17:27:35.580Z

                                            Hello Joe,

                                            this line:

                                            var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Bounced Files';
                                            

                                            is directing you to the Bounced Files folder, change it to

                                            var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/Audio Files';
                                            

                                            to go to the Audio Files

                                            then, add this line:

                                             navigateToInDialog(folderPath) 
                                            
                                            1. Joe Costable @Joe_Costable
                                                2022-09-22 17:34:25.421Z

                                                Ah, I see how I worded that wrong. It's actually not navigating to the bounced files folder like I want, It's going to the audio files folder. So I'm guessing I'm just missing that "navigateToInDialog" line...

                                                Thanks!

                                                1. JJustin Flynn @Justin_Flynn
                                                    2025-03-26 23:56:22.314Z

                                                    and to just have it navigate it to the session folder root should look like?

                                                    var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + '/';

                                                    something like that?