OS Print Rename custom script failing on new OS
Title
OS Print Rename custom script failing on new OS
What do you expect to happen when you run the script/macro?
The script is now failing using Sequoia and i'm unsure how to rectify it.
It should run all the way to the end but is failing right after opening the save to dialog box.
Are you seeing an error?
06.03.2025 09:40:30.30 [Backend]: #App: Activate "com.avid.ProTools" -> 1. MikeDeck Mix [cm7h062t80001uu104wonakto]
06.03.2025 09:40:30.30 [Backend]: [AxDeckInstance] InstanceShow: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.727146f1-73be-49de-a25e-c12b11f21408 (1. MikeDeck Mix) Device: 'CL43J1A02403'
[AxStreamDeckDevice id#1] Device 'CL43J1A02403' -> ShowDeckInstance: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.727146f1-73be-49de-a25e-c12b11f21408
06.03.2025 09:40:33.76 [Backend]: #StreamDeck: KeyDown (8,4) -> 2. Export Selected Deck
06.03.2025 09:40:33.76 [Backend]: >> Command: 2. Export Selected Deck [user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh]
06.03.2025 09:40:33.76 [Backend]: [AxDeckInstance] Setting up render frequency at 15 frames/sec, equalling 66 ms per render
[AxDeckInstance] InstanceShow: user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh:streamDeckHid.CL43J1A02403.0f6858ea-39c6-4cb1-b853-c63ba24f8134 (2. Export Selected Deck) Device: 'CL43J1A02403'
[AxStreamDeckDevice id#1] Device 'CL43J1A02403' -> ShowDeckInstance: user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh:streamDeckHid.CL43J1A02403.0f6858ea-39c6-4cb1-b853-c63ba24f8134
[AxStreamDeckDevice id#1] HideDeckInstance
<< Command: 2. Export Selected Deck [user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh]
06.03.2025 09:40:34.87 [Backend]: #StreamDeck: KeyDown (8,4) -> Bobby OS Print Renaming (Standard)
06.03.2025 09:40:34.87 [Backend]: >> Command: Bobby OS Print Renaming (Standard) [user:ckm84ophk0000qm10v8mskflw:ckmcg88v90001hy10h3ea8bs1]
06.03.2025 09:40:34.87 [Backend]: [NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'
NSArray.ArrayFromHandle count = 1
06.03.2025 09:40:34.95 [Backend]: Mouse current pos is: (1662.9609375, 656.984375)
Clicking with mouse here: (10, 60)
06.03.2025 09:40:34.96 [Backend]: Moving mouse back to: (1662.9609375, 656.984375)
06.03.2025 09:40:34.97 [Backend]: Position is now: (1662.9609375, 656.984375)
06.03.2025 09:40:34.99 [Backend]: [WithFrontmostAppPreservedAction] Saving the current frontmost app 'com.avid.ProTools' before running callback...
06.03.2025 09:40:36.22 [Backend]: [WithFrontmostAppPreservedAction] Re-activating the app 'com.avid.ProTools' after callback...
[NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'
NSArray.ArrayFromHandle count = 0
06.03.2025 09:40:36.28 [Backend]: [NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'
06.03.2025 09:40:36.28 [Backend]: NSArray.ArrayFromHandle count = 1
06.03.2025 09:40:36.28 [Backend]: #App: Activate "com.avid.ProTools" -> 1. MikeDeck Mix [cm7h062t80001uu104wonakto]
06.03.2025 09:40:36.28 [Backend]: [WithFrontmostAppPreservedAction] Re-activation succeeded after 0.01 seconds
06.03.2025 09:40:36.29 [Backend]: [NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'
06.03.2025 09:40:36.30 [Backend]: NSArray.ArrayFromHandle count = 1
06.03.2025 09:40:36.38 [Backend]: Mouse current pos is: (1662.9609375, 656.984375)
Clicking with mouse here: (10, 60)
06.03.2025 09:40:36.39 [Backend]: Moving mouse back to: (1662.9609375, 656.984375)
06.03.2025 09:40:36.39 [Backend]: Position is now: (1662.9609375, 656.984375)
06.03.2025 09:40:37.62 [Backend]: Logging error in action (01) WaitForElementAction: Element was not found or removed after waiting 500 ms
06.03.2025 09:40:37.62 [Backend]: !! Command Error: Bobby OS Print Renaming (Standard) [user:ckm84ophk0000qm10v8mskflw:ckmcg88v90001hy10h3ea8bs1]:
Could not find "Go to" sheet in the Save/Open dialog (Bobby OS Print Renaming (Standard): Line 60)
Element was not found or removed after waiting 500 ms
<< Command: Bobby OS Print Renaming (Standard) [user:ckm84ophk0000qm10v8mskflw:ckmcg88v90001hy10h3ea8bs1]
06.03.2025 09:40:37.62 [Backend]: [AxDeckInstance] InstanceShow: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.fd952dd2-8464-4c3d-b08c-deb688f58ce7 (1. MikeDeck Mix) Device: 'CL43J1A02403'
[AxStreamDeckDevice id#1] Device 'CL43J1A02403' -> ShowDeckInstance: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.fd952dd2-8464-4c3d-b08c-deb688f58ce7
[AxStreamDeckDevice id#1] HideDeckInstance
06.03.2025 09:40:37.62 [Backend]: [AxDeckInstance] Setting up render frequency at 15 frames/sec, equalling 66 ms per render
What happens when you run this script?
N/A
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
5
Details
{ "inputExpected": "The script is now failing using Sequoia and i'm unsure how to rectify it.\n\nIt should run all the way to the end but is failing right after opening the save to dialog box.", "inputIsError": true, "inputError": "\n06.03.2025 09:40:30.30 [Backend]: #App: Activate \"com.avid.ProTools\" -> 1. MikeDeck Mix [cm7h062t80001uu104wonakto]\n\n06.03.2025 09:40:30.30 [Backend]: [AxDeckInstance] InstanceShow: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.727146f1-73be-49de-a25e-c12b11f21408 (1. MikeDeck Mix) Device: 'CL43J1A02403'\n[AxStreamDeckDevice id#1] Device 'CL43J1A02403' -> ShowDeckInstance: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.727146f1-73be-49de-a25e-c12b11f21408\n\n06.03.2025 09:40:33.76 [Backend]: #StreamDeck: KeyDown (8,4) -> 2. Export Selected Deck\n\n06.03.2025 09:40:33.76 [Backend]: >> Command: 2. Export Selected Deck [user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh]\n\n06.03.2025 09:40:33.76 [Backend]: [AxDeckInstance] Setting up render frequency at 15 frames/sec, equalling 66 ms per render\n[AxDeckInstance] InstanceShow: user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh:streamDeckHid.CL43J1A02403.0f6858ea-39c6-4cb1-b853-c63ba24f8134 (2. Export Selected Deck) Device: 'CL43J1A02403'\n[AxStreamDeckDevice id#1] Device 'CL43J1A02403' -> ShowDeckInstance: user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh:streamDeckHid.CL43J1A02403.0f6858ea-39c6-4cb1-b853-c63ba24f8134\n[AxStreamDeckDevice id#1] HideDeckInstance\n<< Command: 2. Export Selected Deck [user:ckgoeq9bq0005h210sxgx36ni:cklvejxf2000efx10e4sqdzoh]\n\n06.03.2025 09:40:34.87 [Backend]: #StreamDeck: KeyDown (8,4) -> Bobby OS Print Renaming (Standard)\n\n06.03.2025 09:40:34.87 [Backend]: >> Command: Bobby OS Print Renaming (Standard) [user:ckm84ophk0000qm10v8mskflw:ckmcg88v90001hy10h3ea8bs1]\n\n06.03.2025 09:40:34.87 [Backend]: [NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'\nNSArray.ArrayFromHandle count = 1\n\n06.03.2025 09:40:34.95 [Backend]: Mouse current pos is: (1662.9609375, 656.984375)\nClicking with mouse here: (10, 60)\n\n06.03.2025 09:40:34.96 [Backend]: Moving mouse back to: (1662.9609375, 656.984375)\n\n06.03.2025 09:40:34.97 [Backend]: Position is now: (1662.9609375, 656.984375)\n\n06.03.2025 09:40:34.99 [Backend]: [WithFrontmostAppPreservedAction] Saving the current frontmost app 'com.avid.ProTools' before running callback...\n\n06.03.2025 09:40:36.22 [Backend]: [WithFrontmostAppPreservedAction] Re-activating the app 'com.avid.ProTools' after callback...\n[NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'\nNSArray.ArrayFromHandle count = 0\n\n06.03.2025 09:40:36.28 [Backend]: [NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'\n\n06.03.2025 09:40:36.28 [Backend]: NSArray.ArrayFromHandle count = 1\n\n06.03.2025 09:40:36.28 [Backend]: #App: Activate \"com.avid.ProTools\" -> 1. MikeDeck Mix [cm7h062t80001uu104wonakto]\n\n06.03.2025 09:40:36.28 [Backend]: [WithFrontmostAppPreservedAction] Re-activation succeeded after 0.01 seconds\n\n06.03.2025 09:40:36.29 [Backend]: [NSRunningApplication (static)] Checking for running apps with bundle 'com.avid.ProTools'\n\n06.03.2025 09:40:36.30 [Backend]: NSArray.ArrayFromHandle count = 1\n\n06.03.2025 09:40:36.38 [Backend]: Mouse current pos is: (1662.9609375, 656.984375)\nClicking with mouse here: (10, 60)\n\n06.03.2025 09:40:36.39 [Backend]: Moving mouse back to: (1662.9609375, 656.984375)\n\n06.03.2025 09:40:36.39 [Backend]: Position is now: (1662.9609375, 656.984375)\n\n06.03.2025 09:40:37.62 [Backend]: Logging error in action (01) WaitForElementAction: Element was not found or removed after waiting 500 ms\n\n06.03.2025 09:40:37.62 [Backend]: !! Command Error: Bobby OS Print Renaming (Standard) [user:ckm84ophk0000qm10v8mskflw:ckmcg88v90001hy10h3ea8bs1]:\nCould not find \"Go to\" sheet in the Save/Open dialog (Bobby OS Print Renaming (Standard): Line 60)\n Element was not found or removed after waiting 500 ms\n\n<< Command: Bobby OS Print Renaming (Standard) [user:ckm84ophk0000qm10v8mskflw:ckmcg88v90001hy10h3ea8bs1]\n\n06.03.2025 09:40:37.62 [Backend]: [AxDeckInstance] InstanceShow: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.fd952dd2-8464-4c3d-b08c-deb688f58ce7 (1. MikeDeck Mix) Device: 'CL43J1A02403'\n[AxStreamDeckDevice id#1] Device 'CL43J1A02403' -> ShowDeckInstance: user:ckgoeq9bq0005h210sxgx36ni:cm7gz11mw0001ed10y328n7g1:streamDeckHid.CL43J1A02403.fd952dd2-8464-4c3d-b08c-deb688f58ce7\n[AxStreamDeckDevice id#1] HideDeckInstance\n\n06.03.2025 09:40:37.62 [Backend]: [AxDeckInstance] Setting up render frequency at 15 frames/sec, equalling 66 ms per render\n\n", "inputWhatHappens": "N/A", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 5, "inputTitle": "OS Print Rename custom script failing on new OS" }
Source
const exportSettings = {
fileType: 'WAV',
format: 'Interleaved',
bitDepth: '24 Bit',
sampleRate: '48 kHz',
enforceAvidCompatibility: 'Disable'
};
const sessionPath = sf.ui.proTools.mainWindow.invalidate().sessionPath;
const sessionDirectory = sessionPath.split('/').slice(0, -1).join('/');
const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
function makeNewDirectory({ templatePath }) {
const parentDirectory = templatePath.split('/').slice(0, -1).join('/');
const directoryTemplateName = templatePath.split('/').slice(-1)[0];
for (let i = 1; ; i++) {
let directoryName = `${directoryTemplateName}${i}`;
let directoryPath = parentDirectory + '/' + directoryName.toLocaleUpperCase();
if (!sf.file.directoryExists({ path: directoryPath }).exists) {
sf.file.directoryCreate({ path: directoryPath });
return directoryPath;
}
}
}
/**
* @param {String} path
*/
function exportAudio(path) {
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is("Clip List").first.popupMenuSelect({
menuPath: ["Export Clips as Files..."],
});
const exportSelectedWin = sf.ui.proTools.windows.whoseTitle.is("Export Selected").first;
exportSelectedWin.elementWaitFor();
setExportSettings(exportSettings);
exportSelectedWin.buttons.whoseTitle.is("Choose...").first.elementClick();
const openWin = sf.ui.proTools.windows.whoseTitle.is("Open").first
openWin.elementWaitFor();
//Open sheet to navigate to new bounce folder
sf.keyboard.press({
keys: "slash",
});
openWin.sheets.first.children.whoseRole.is("AXStaticText").whoseValue.is("Go to the folder:").first.elementWaitFor();
openWin.sheets.first.comboBoxes.whoseValue.is("/").first.elementSetTextFieldWithAreaValue({
value: path,
});
openWin.sheets.first.buttons.whoseTitle.is("Go").first.elementClick();
openWin.buttons.whoseTitle.is("Open").first.elementClick();
openWin.elementWaitFor({
waitType: "Disappear",
});
sf.ui.proTools.windows.whoseTitle.is("Export Selected").first.buttons.whoseTitle.is("Export...").first.elementClick();
exportSelectedWin.elementWaitFor({
waitType: "Disappear",
});
sf.ui.proTools.waitForNoModals();
}
function setExportSettings(exportSettings) {
const { fileType, format, bitDepth, sampleRate, enforceAvidCompatibility } = exportSettings;
const exportWin = sf.ui.proTools.windows.whoseTitle.is("Export Selected").first;
//Set File Type
if (exportWin.popupButtons.allItems[3].value.invalidate().value !== fileType)
exportWin.popupButtons.allItems[3].popupMenuSelect({ menuPath: [fileType] });
//Set Format
if (exportWin.popupButtons.allItems[2].value.invalidate().value !== format)
exportWin.popupButtons.allItems[2].popupMenuSelect({ menuPath: [format] });
//Set Bit Depth
if (exportWin.popupButtons.allItems[1].value.invalidate().value !== bitDepth)
exportWin.popupButtons.allItems[1].popupMenuSelect({ menuPath: [bitDepth] });
//Set Sample Rate
if (exportWin.popupButtons.first.value.invalidate().value !== sampleRate)
exportWin.popupButtons.first.popupMenuSelect({ menuPath: [sampleRate] });
//Set Avid Compatability
exportWin.checkBoxes.whoseTitle.is("Enforce Avid Compatibility").first.checkboxSet({
targetValue: enforceAvidCompatibility,
});
//Select Prompt for Duplication
exportWin.radioButtons.whoseTitle.is("Prompting For Each Duplicate").first.elementClick();
}
/**
* @param {String} filePath
* @param {String} prefix
*/
function adjustFileName(filePath, prefix) {
//Extract filename from path
const fileName = filePath.split('/').slice(-1).join('/').toString();
//Regex
// _ - Remove underscore
// \d+ - Remove number of any length
// ?=. - Everything up until the period
let trimmedFileName = fileName.replace(/(_\d+)(?=.)/, '');
//Extract Directory from path
const oldFileDirectoryPath = filePath.split('/').slice(0, -1).join('/').toString();
//Create new file path
const newFilePath = `${oldFileDirectoryPath}/${prefix}_${trimmedFileName}`;
//Change file path
sf.file.move({
sourcePath: filePath,
destinationPath: newFilePath,
});
}
function main() {
sf.ui.proTools.appActivateMainWindow();
//Is Clips list open?
const oldClipsViewState = sf.ui.proTools.getMenuItem('View', 'Other Displays', 'Clip List').isMenuChecked;
//Ensure clips list open
sf.ui.proTools.menuClick({
menuPath: ['View', 'Other Displays', 'Clip List'],
targetValue: "Enable"
});
//Check to see if the user would like to proceed.
const confirmation = confirm('Are you ready to awesomness?');
if (!confirmation) throw 0
// ( |_) = Match space or Underscore
// (Mix) = Match "Mix"
// [\s\S]* = Match anything till end of string
// i = Ignore case
const trimmedSessionName = sessionName.replace(/( |_)(Mix)[\s\S]*/i, '');
//Create New Directory
const newDirectory = makeNewDirectory({
templatePath: `${sessionDirectory}/Bounced Files/${trimmedSessionName}_MIX `
});
//Export Audio
exportAudio(newDirectory);
//Get the paths of selected files in the newly created directory
let filePaths = sf.file.directoryGetFiles({ path: newDirectory }).paths;
//For each path add prefix to the file name
filePaths.forEach(path => adjustFileName(path, trimmedSessionName));
//Restore Clips list
if (!oldClipsViewState) {
sf.ui.proTools.menuClick({
menuPath: ['View', 'Other Displays', 'Clip List'],
targetValue: "Disable"
});
}
//Open Directory
sf.appleScript.finder.open(newDirectory);
//Switch to Finder
sf.ui.finder.appActivateMainWindow();
}
main();
Links
User UID: DFxsXNS2zjMTRP4UySE16jIeYpc2
Feedback Key: sffeedback:DFxsXNS2zjMTRP4UySE16jIeYpc2:-OKgYcafeNDF1idHBA_3
Feedback ZIP: 9RtKoI0ljfj4WkuCQoXvGkOIsGfkWgpuxa0ksBfrlOR4nohamJ+dFqTOlQoDD1usoxaMNmkHTeqVH4zyiuDsae+oDpGv6qqqlkoNVC6LzV/ZA5aFk3Ojwg0hgzMC1XBtBkNA1jc1dUkXw4I9XhVM2taUapcK1BqNhOjVrKZ00gLIgMFfhhnvs949gjbk1YUdFOTdkHzXz6Yj/sLW0cMwb/4fo1wAoeWGUGFYs7NAxB4ts14RrvZwfh2nsrLNXzTS58QaTR9NoBJp9tHLy9PHRgCwcBE3sqFE/O9SeAXcMYX41XL2LE7F/gRun6cWWv5af4yLm0oNXa7/Y9TTce+bUQ==