from pro tools export files window, navigate to session root bounced files folder
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 },
});
- samuel henriques @samuel_henriques
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 - In reply tosamuel_henriques⬆:Joe Costable @Joe_Costable
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();
samuel henriques @samuel_henriques
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.
Joe Costable @Joe_Costable
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", });
- In reply tosamuel_henriques⬆:OOren Hadar @Oren_Hadar
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?
samuel henriques @samuel_henriques
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!
- OOren Hadar @Oren_Hadar
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
- In reply tosamuel_henriques⬆:Joe Costable @Joe_Costable
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';
samuel henriques @samuel_henriques
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'); };
Joe Costable @Joe_Costable
Works- Thanks!
- In reply tosamuel_henriques⬆:
Joe Costable @Joe_Costable
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", });
samuel henriques @samuel_henriques
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)
Joe Costable @Joe_Costable
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!
- In reply tosamuel_henriques⬆:JJustin Flynn @Justin_Flynn
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?