SFX filePaths property does not handle paths starting with Tilde
Title
SFX filePaths property does not handle paths starting with Tilde
Content type
script
Content name
Export Selected Tracks w Audio
Content package
Default Package
Version info
OS: macOS 15.7.1
SoundFlow: 6.0.1
Pro Tools: 25.10.0.144
What do you expect to happen when you run the script?
Export selected tracks to new session
Are you seeing an error?
Could not save a copy in "~/Desktop/Export test pt" because Assertion in "/Users/autobld/gitlabci/PT/release/2025/r2/ ProTools/NewFileLibs/Sys/MacOS/Sys_FileLocМacOS.сpр", line 231.
What happens when you run the script?
This script works fine as is now. The problem has to do with resolving Finder paths that start with the Tilde when using the filePaths property. They don't correctly point to the /Users/whomever/
How were you running this script?
Other
How important is this issue to you?
3
Details
{
"textExpected": "Export selected tracks to new session",
"textError": "Could not save a copy in \"~/Desktop/Export test pt\" because Assertion in \"/Users/autobld/gitlabci/PT/release/2025/r2/ ProTools/NewFileLibs/Sys/MacOS/Sys_FileLocМacOS.сpр\",\nline 231.",
"textWhatHappens": "This script works fine as is now. The problem has to do with resolving Finder paths that start with the Tilde when using the filePaths property. They don't correctly point to the /Users/whomever/",
"inputHowRun": "Other",
"inputImportance": 3,
"textTitle": "SFX filePaths property does not handle paths starting with Tilde"
}
Source
/**
* Export selected tracks to a new session.
*
* @param {string} path - Target folder path (e.g. "~/Desktop/Exports")
* @param {string} name - Base session name (e.g. "MySong")
* @param {string} suffix - Optional name suffix (e.g. "Guitars")
*/
function exportSelectedTracks(path, name, suffix = "") {
if (!sf.ui.proTools.selectedTrackCount) return;
path = resolveHomePath(path);
// Combine name and suffix safely (no trailing space)
const fullName = suffix ? `${name} ${suffix}` : name;
// Build paths
let sessionFolder = `${path}/${fullName}`;
sessionFolder = getUniqueFolderPath(sessionFolder);
// const sessionName = `${fullName}.ptx`;
// const sessionFilePath = `${sessionFolder}/${sessionName}`;
const sessionFilePath = `${sessionFolder}.ptx`;
const usingSfx = typeof sf.ui.useSfx === "function";
// Handles the "Save Copy In" dialog
const exportAction = () => {
const win = sf.ui.proTools.windows.whoseTitle.is("Save Copy In...").first;
win.elementWaitFor();
const audioFilesBox = win.checkBoxes.whoseTitle.is("Audio Files").first;
if (!audioFilesBox.value.value) audioFilesBox.elementClick();
win.buttons.whoseTitle.is("OK").first.elementClick();
win.elementWaitFor({ waitType: "Disappear" });
};
if (usingSfx) {
sf.ui.useSfx({ value: "On" });
sf.ui.proTools.menuClick({
menuPath: ['File', 'Export', 'Selected Tracks as New Session...'],
filePaths: [sessionFilePath],
});
exportAction();
sf.ui.useSfx({ value: "Off" });
} else {
sf.ui.proTools.menuClick({
menuPath: ['File', 'Export', 'Selected Tracks as New Session...'],
});
exportAction();
navigateToInDialog(sessionFolder);
const saveWin = sf.ui.proTools.windows.whoseTitle.is('Save').first;
saveWin.buttons.whoseTitle.is('Save').first.elementClick();
saveWin.elementWaitFor({ waitForNoElement: true });
}
}
/**
* Expand ~ to absolute home path.
*/
function resolveHomePath(path) {
if (path.startsWith('~/')) {
const home = sf.appleScript.finder.home.path.toString();
return path.replace(/^~\/?/, home.endsWith('/') ? home : home + '/');
}
return path;
}
/**
* Returns a unique folder path by appending _1, _2, etc. if needed.
*/
function getUniqueFolderPath(basePath) {
let counter = 1;
let uniquePath = basePath;
while (sf.file.directoryExists({path: uniquePath}).exists) {
uniquePath = `${basePath}_${counter}`;
counter++;
}
return uniquePath;
}
exportSelectedTracks('~/Desktop', 'Exported', '');
Links
User UID: 2FEbvmxaByaWbeBh5fRIjEwuOjA3
Feedback Key: sffeedback:2FEbvmxaByaWbeBh5fRIjEwuOjA3:-OdAT1aWBfk8k4e54Qhe
Feedback ZIP: 0mh4GY3crk/92QFnK1MG6+XmDhI1Bfbim7/wxJbICbR7KyoOMB81TSwoT0QkQJeI0FAcadKAALd4Wmwdp9nYF9GKQcaWECSM+tlTH4HQX3Ctu6zM/AVNDPSUZD3u+oDkftryrISOfAMAfYwUHRrmP6urB8/JF/YOq0qA4dDBXak+EQtJrp/XG44hW81WyuiR+M93O+Ja/Ez/HItKWIFGkkE3mXct9hCznk9NnGWw7Ksd2vYScUuGfcXn7Lg86JqOsvTZ2ogGLmEPiI8qhUjaEkPrdKf+991Gly3QA0GWFId/yiaQHW8PKGr5vmQEI7lHEcfQuyy+lqF87dokvXbHMg==
Linked from:
Matt Friedman @Matt_FriedmanI'm using a custom function
resolveHomePathto turn paths like~/Desktopinto/Users/matt/Desktopbut AFAIK this is something SF already does internally traditionally. However it does not seem to be doing it in this particular function (exporting a session using SFX) automatically, hence I needed my own function to do it.
Kitch Membery @Kitch2025-11-03 23:15:49.002ZThanks for logging this! We're tracking this issue internally and will let you know once it has been addressed. :-)
- SIn reply toMatt_Friedman⬆:SoundFlow Bot @soundflowbot
This report was now added to the internal issue tracked by SoundFlow as SF-3090