No internet connection
  1. Home
  2. How to

Working on series of Pro Tools sessions in bulk

By Udi Simhon @Udi_Simhon
    2023-12-17 09:17:52.091Z

    Hello,

    I'm currently engaged in a series of Pro Tools sessions in bulk, and I'm wondering if it's possible to create a script that can open each session, execute a script, and then save session.

    Thank you,
    Udi

    Solved in post #14, click to view
    • 12 replies
    1. Hi Udi,

      Yes, this is possible, but may require a lot of work to get working in all cases (handling potential warning dialogs popping up, etc.). Bounce Factory does this, for example.

      The basics would just be clicking to Close Session via the menu, and then Open Session via the menu, and then navigating in a file open dialog to choose the right file (search for navigateInDialog or look in the "Navigate to top-most Finder window in Save/Open dialog" script which is in the official Pro Tools package).

      1. Actually, I forgot, you can also close & open sessions via the new SDK functions. It won't solve potential warning dialogs, but saves you navigating in dialogs.

        sf.app.proTools.closeSessionSavingFirst();
        

        Open session:

        sf.app.proTools.openSession({
            sessionPath: `~/Desktop/My Project.ptx`,
        });
        
        1. You'll likely need to add some error handling and re-try logic in cases where the code gets stuck waiting on Pro Tools (for example if PT is unresponsive during session load - depends on the sizes of sessions and the power of your CPU).

      2. U
        In reply toUdi_Simhon:
        Udi Simhon @Udi_Simhon
          2023-12-17 12:46:58.896Z

          Thank you.

          None of the Pro Tools sessions display any dialogue pop-ups as they are all empty and based on the same template. I'm curious if there's a method to scan a designated folder containing .ptx files, execute a script, and then proceed to the next session in that folder.

          1. Yes, you could do that too.

            Something like this should get you started:

            
            function processSession(path) {
                sf.app.proTools.openSession({
                    sessionPath: path,
                });
            
                //
                alert(`Here's where you'd do something with this session`);
            
                sf.app.proTools.closeSessionSavingFirst();
            }
            
            function main() {
                const folderPath = '~/Desktop/PT_Sessions';
            
                const ptxPaths = sf.file.directoryGetFiles({
                    path: folderPath,
                    searchPattern: '*.ptx',
                    sortOrder: 'NameAsc',
                }).paths;
            
                for(let ptxPath of ptxPaths) {
                    processSession(ptxPath);
                }
            }
            
            main();
            
            1. UUdi Simhon @Udi_Simhon
                2023-12-17 13:04:00.653Z

                Awesome!
                Suppose I want to execute a script named "Import Files and Rename Tracks." How can I integrate it into this script?

                1. Instead of the alert line, you'd insert a call to run your command.

                  sf.soundflow.runCommand({
                      commandId: 'INSERT_COMMAND_ID_HERE',
                  });
                  

                  The INSERT_COMMAND_ID_HERE would need to be replaced with the command ID of the command you want to run. To get that, select the script/macro in the command list, hit Cmd+C, go into this script and hit Cmd+V.

                  1. I would recommend testing the previous script I shared though to see that it properly opens and closes sessions first, before integrating the commands together. Without proper error handling and re-try logic, this could very well become brittle.

                    1. In reply tochrscheuer:
                      UUdi Simhon @Udi_Simhon
                        2023-12-17 13:22:48.694Z2023-12-17 14:34:53.942Z

                        When I tried this script:

                        
                        function processSession(path) {
                            sf.app.proTools.openSession({
                                sessionPath: path,
                            });
                        
                            //
                            sf.soundflow.runCommand({
                            commandId: 'user:clp00xu1a0000gw10kszjhh4p:clq6nf84v0001pz10rceh8wyp',
                        });
                        
                            sf.app.proTools.closeSessionSavingFirst();
                        }
                        
                        function main() {
                            const folderPath = ''; //redacted
                        
                            const ptxPaths = sf.file.directoryGetFiles({
                                path: folderPath,
                                searchPattern: '*.ptx',
                                sortOrder: 'NameAsc',
                            }).paths;
                        
                            for(let ptxPath of ptxPaths) {
                                processSession(ptxPath);
                            }
                        }
                        
                        main();
                        

                        I got an Error of "Cannot convert a Symbol value to a string"

                        Here is the log

                        17.12.2023 15:20:52.87 [EditorWindow:Renderer]: Active Focus Container: code Line 33963 file:///Applications/SoundFlow.app/Contents/Helpers/SoundFlow.app/Contents/Resources/app.asar/dist/editor.js
                        17.12.2023 15:20:54.06 [EditorWindow:Renderer]: Calling backendwebclient sendasync: /commands/run [object Object] Line 56463 file:///Applications/SoundFlow.app/Contents/Helpers/SoundFlow.app/Contents/Resources/app.asar/dist/editor.js
                        17.12.2023 15:20:54.06 [Backend]: Received run command: user:clp00xu1a0000gw10kszjhh4p:clq9i3dfr0005kv106dmixtl3
                        [ServerController] Running command from sfgui: 'test' (user:clp00xu1a0000gw10kszjhh4p:clq9i3dfr0005kv106dmixtl3)

                        17.12.2023 15:20:54.06 [Backend]: >> Command: test [user:clp00xu1a0000gw10kszjhh4p:clq9i3dfr0005kv106dmixtl3]

                        17.12.2023 15:20:54.08 [StartMenu]: StartMenuContainer currentPageKey='home' Line 24630 file:///Applications/SoundFlow.app/Contents/Helpers/SoundFlow.app/Contents/Resources/app.asar//dist/bundle.js
                        17.12.2023 15:20:54.12 [Backend]: JavaScript error with InnerException: null

                        17.12.2023 15:20:54.12 [Backend]: !! Command Error: test [user:clp00xu1a0000gw10kszjhh4p:clq9i3dfr0005kv106dmixtl3]:
                        TypeError: Cannot convert a Symbol value to a string
                        (test line 24)

                        << Command: test [user:clp00xu1a0000gw10kszjhh4p:clq9i3dfr0005kv106dmixtl3]

                        17.12.2023 15:20:54.12 [StartMenu]: StartMenuContainer currentPageKey='home' Line 24630 file:///Applications/SoundFlow.app/Contents/Helpers/SoundFlow.app/Contents/Resources/app.asar//dist/bundle.js
                        17.12.2023 15:20:54.12 [StartMenu]: StartMenuContainer currentPageKey='home' Line 24630 file:///Applications/SoundFlow.app/Contents/Helpers/SoundFlow.app/Contents/Resources/app.asar//dist/bundle.js

                        1. Change this line:

                          for(let ptxPath of ptxPaths) {
                          

                          to:

                          for(let ptxPath of Array.from(ptxPaths)) {
                          
                          1. UUdi Simhon @Udi_Simhon
                              2023-12-17 14:47:49.493Z

                              Thank you for your efforts!
                              The progress looks promising, but there seems to be an inconsistency in its functionality. It often gets stuck midway, and I suspect it may be related to waiting times, among other factors.
                              Could we incorporate a step to "Wait for the Pro Tools app to become active" before executing the script within Pro Tools?

                              1. Yea exactly, that's the kind of stuff you'd need to work on. I won't have time to go into all that myself, but you may be able to get some help from the community on how to build this. It's the kind of thing that may take a long time to make stable, as I mentioned before, due to all the various ways PT can be unresponsive during session load etc.

                                Please note we also offer paid script services where a team member can write scripts for you - please be in touch on support@soundflow.org if you're interested.

                                Reply1 LikeSolution