Pro Tools Disk Allocation script causing a pro tools error.
Title
Pro Tools Disk Allocation script causing a pro tools error.
What do you expect to happen when you run the script/macro?
This script (not mine, I've just adjusted it to suit what I wanted) selects my print tracks and changes the disk allocation to a folder it creates inside my session folder which takes its name from the session file. I've also adjusted it so it doesn't create an Audio Files folder in that folder, but prints directly into it.
Are you seeing an error?
What happens when you run this script?
The script works perfectly, the issue is a pro-tools one: if I close and open the session file I get an error saying it can no longer use the previous disk allocation and I have to set it again. The drive is set to Record (not transfer only) and the previously selected folder is still there and unpopulated so not sure why this method has an error.
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
5
Details
{ "inputExpected": "This script (not mine, I've just adjusted it to suit what I wanted) selects my print tracks and changes the disk allocation to a folder it creates inside my session folder which takes its name from the session file. I've also adjusted it so it doesn't create an Audio Files folder in that folder, but prints directly into it. ", "inputIsError": false, "inputWhatHappens": "The script works perfectly, the issue is a pro-tools one: if I close and open the session file I get an error saying it can no longer use the previous disk allocation and I have to set it again. The drive is set to Record (not transfer only) and the previously selected folder is still there and unpopulated so not sure why this method has an error.", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 5, "inputTitle": "Pro Tools Disk Allocation script causing a pro tools error." }
Source
//Populate Text String
const sessionPath = sf.ui.proTools.mainWindow.sessionPath;
const sessionName = sessionPath.split("/").slice(-1)[0].split(".ptx")[0]
const selection = sf.ui.proTools.selectionGet();
//Construct Clipboard
const PopulateClipboard = `${sessionName}`
//Populate Clipboard
sf.clipboard.setText({
text: PopulateClipboard
});
function getGroupListItem(name) {
var groupList = sf.ui.proTools.mainWindow.tables.whoseTitle.contains('Group').first;
return groupList.childrenByRole("AXRow").allItems.map(function (r) {
return {
row: r,
selectBtn: r.childrenByRole("AXCell").first.children.first,
name: r.childrenByRole("AXCell").allItems[1].children.first.title.value.match(/^.+ - ([^(]+)/)[1].replace(/ $/, ''),
};
}).filter(function (r) { return r.name == name })[0];
}
var groupListItem = getGroupListItem("PRINTS");
groupListItem.selectBtn.elementClick();
function setCustomDiskAllocationOfSelectedTracks() {
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.mainWindow.invalidate();
const selectedTrackNames = sf.ui.proTools.selectedTrackNames;
const diskAllocationWindow = sf.ui.proTools.windows.whoseTitle.is("Disk Allocation").first;
if (!selectedTrackNames.length) {
throw "No tracks selected.\nPlease select one or more tracks and try again."
}
sf.ui.proTools.menuClick({ menuPath: ['Setup', 'Disk Allocation...'] });
diskAllocationWindow.elementWaitFor();
const table = diskAllocationWindow.tables.whoseTitle.is("Disc Allocation").first;
const tableRows = table.children.whoseRole.is("AXRow").map(row => row);
const targetRows = tableRows.filter(row => {
const staticText = row.children.whoseRole.is("AXCell").first
.children.whoseRole.is("AXStaticText").first;
return selectedTrackNames.includes(staticText.title.value);
});
// Set Checkboxes
sf.ui.proTools.windows.whoseTitle.is("Disk Allocation").first.checkBoxes.whoseTitle.is("Custom Allocation Options").first.checkboxSet({
targetValue: "Enable",
});
sf.ui.proTools.windows.whoseTitle.is("Disk Allocation").first.checkBoxes.whoseTitle.is("Create subfolders for audio, video, and fade files").first.checkboxSet({
targetValue: "Disable",
});
sf.ui.proTools.windows.whoseTitle.is("Disk Allocation").first.checkBoxes.whoseTitle.is("Use round robin allocation for new tracks").first.checkboxSet({
targetValue: "Disable",
});
// Select tracks in Disk Allocation Window
targetRows.forEach(row =>
row.children.whoseRole.is("AXCell").first.elementClick()
);
// Open up popup menu from the first selected track
targetRows[0]
.children.whoseRole.is("AXCell").allItems[1]
.children.whoseRole.is("AXMenuButton").first
.elementClick({ asyncSwallow: true });
// Choose the "Select Folder..." option via keyboard
sf.keyboard.press({
keys: "return",
});
// Wait for the "Open" window to come up
sf.ui.proTools.windows.whoseTitle.is("Open").first.elementWaitFor();
}
setCustomDiskAllocationOfSelectedTracks();
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;
//It's a combo box on older OS'es, from 12.something it's a text field
if (sheet.comboBoxes.first.exists) {
sheet.comboBoxes.first.value.value = path;
//Press OK
sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
}
else {
//Newer OS.
//TextField with AXConfirm
var textField = sheet.textFields.first;
if (!textField.exists) throw `Can't find text field`;
textField.value.value = path;
sheet.elementRaise();
textField.mouseClickElement({
relativePosition: { x: 5, y: 5 },
});
sf.keyboard.press({ keys: 'return' });
}
//Wait for sheet to close
win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 2500 }, '"Go to" sheet didn\'t close in time');
}
var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/')
navigateToInDialog(folderPath);
// New Folder
sf.keyboard.press({
keys: "cmd+shift+n",
});
sf.wait({
intervalMs: 500,
});
sf.keyboard.press({
keys: "cmd+v",
});
sf.keyboard.press({
keys: "return",
});
sf.wait({
intervalMs: 500,
});
sf.keyboard.press({
keys: "return",
});
sf.wait({
intervalMs: 500,
});
sf.keyboard.press({
keys: "return",
});
Links
User UID: IPoX41BJQfW8Jfm5DwC4SC8wDo33
Feedback Key: sffeedback:IPoX41BJQfW8Jfm5DwC4SC8wDo33:-OWVn2kYCeDNocbhjTFn
Feedback ZIP: sBfzeT/2F7xUOOTa6jFFlq3/dIZUXI1Vz1MgauxMMdX9f6xiNepoDLWepTNHRMmcSFB1IfCfWWzlvfW9R2sEES2iCs9LD3Gg/4Ffqfxr8LiB5mjddHRsjsmF9xWfnx/mlkoslzhWvSsp8gxTRMC3EB+WHw320qtrsz3l79D/H5hk9vxciTyN3z1KHdVsx2Gpo8i4oIgXE8N+xJt0KEYpmG62MzjOBTX2f2ONTibGrEt51bJuB/piHMKxjVIjKMRyHQo6LXBGi2J7wwif1mD6S2eeaTh7nbVJTmIoA1i5cNoAVgLCWEA9Y32omzSf8woD2iAlKMR2jWRQv94hvNOl6v0soO7cUe+rApuODQhZ0AE=
- Raphael Sepulveda @raphaelsepulveda2025-08-02 03:31:49.263Z
Hey @T_Francis,
As you indicated in your description, this is Pro Tools misbehaving. I tried both your script and walking through the steps manually and they both yield the same result—a Pro Tools alert coming up when re-opening the session.
The culprit seems to be the combination of turning on the "Custom Allocation Options" checkbox and deselecting the "Create subfolders for audio, video, and fade files" option in the Disk Allocation window. I know you were looking to avoid Pro Tools creating that Audio Files folder but unfortunately there doesn't seem to be another way to do it without bumping into your original problem.
I was going to suggest a secondary script that moves the files out of the Audio Files folder and then deletes it. But then, when you open the session again, it will ask you to relink files, so it's not a perfect solution either.
Looks like we're stumped on this one 😭
- TT Francis @T_Francis
Hi there Raphael, and thanks so much for spending time looking at this, looks like it’s PT having a hissy fit! Back to the old drawing board, I guess…
Thanks again 😊
T