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
- Christian Scheuer @chrscheuer2023-12-17 11:45:40.566Z
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).
Christian Scheuer @chrscheuer2023-12-17 11:46:52.610Z
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`, });
Christian Scheuer @chrscheuer2023-12-17 11:50:03.343Z
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).
- UIn reply toUdi_Simhon⬆:Udi Simhon @Udi_Simhon
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.
Christian Scheuer @chrscheuer2023-12-17 13:01:51.666Z
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();
- UUdi Simhon @Udi_Simhon
Awesome!
Suppose I want to execute a script named "Import Files and Rename Tracks." How can I integrate it into this script?Christian Scheuer @chrscheuer2023-12-17 13:06:12.717Z
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.Christian Scheuer @chrscheuer2023-12-17 13:06:52.374Z
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.
- In reply tochrscheuer⬆:UUdi Simhon @Udi_Simhon
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: null17.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.jsChristian Scheuer @chrscheuer2023-12-17 14:19:03.218Z
Change this line:
for(let ptxPath of ptxPaths) {
to:
for(let ptxPath of Array.from(ptxPaths)) {
- UUdi Simhon @Udi_Simhon
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?Christian Scheuer @chrscheuer2023-12-18 10:34:42.333Z
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.