Title
Replace suffix with new suffix
What do you expect to happen when you run the script/macro?
Save Session As and replace range of text with new text, or suffix.
Are you seeing an error?
What happens when you run this script?
I have gotten it to the point of adding the suffix I want, but I need to remove a range of text at the end of the current name.
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
4
Details
{ "inputExpected": "Save Session As and replace range of text with new text, or suffix.\n\n", "inputIsError": false, "inputWhatHappens": "I have gotten it to the point of adding the suffix I want, but I need to remove a range of text at the end of the current name.\n", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 4, "inputTitle": "Replace suffix with new suffix\n" }
Source
function saveSessionAs(newSessionName) {
sf.ui.proTools.menuClick({ menuPath: ["File", "Save As..."] });
const saveAsWin = sf.ui.proTools.windows.whoseTitle.is('Save').first.elementWaitFor({ waitType: "Appear" }, 'Save as Window Didn\'t Open.').element
saveAsWin.textFields.first.value.value = newSessionName
saveAsWin.buttons.whoseTitle.is('Save').first.elementClick();
saveAsWin.elementWaitFor({ waitType: "Disappear" }, 'Save as Window Didn\'t Close.');
}
function getNewSessionName() {
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.invalidate();
let newSessionName
const sessionPath = sf.ui.proTools.mainWindow.sessionPath;
const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
let sessionVersion = sessionName.match(/\d+$/)
if (!sessionVersion) {
newSessionName = sessionName + "_FULL"
return newSessionName;
};
let versionNumber = +sessionVersion[0];
let cleanSessionName = sessionName.split(/\d+$/)[0];
let newVersion = ++versionNumber <= 9 ? "0" + versionNumber : versionNumber
return cleanSessionName + newVersion
};
let newName = getNewSessionName()
saveSessionAs(newName)
Links
User UID: zNchbgqMvBUNXIhmLZsA7wqfiDl1
Feedback Key: sffeedback:zNchbgqMvBUNXIhmLZsA7wqfiDl1:-NexemPQ7-LPGqRLOuqu
Feedback ZIP: wbS80WJ7cV15TNtl1BbYcRjfgrmixQIR+ajb7z/ma+zx7nNB6ZKiV3/lEUZq//+U9T6HGRNtFq/QUo0efxptSbBZ+jV4hKPhAP7oN+loxeGX4w07wxkuBhFDAyPhElDyuk4KgfdstoMIep6a5VLrb8sKMzMkET5c2XDomnA3e3s87xVT7vSRtzN4Lcmu5QicE8qpat4V3+jc3em0ZmueMxjHaDeEe6m5VYDmATTwlgRuH1u+ehSx7mK1XQSxONvG8WgV/ghaQ/qw0iJ9o0xXQbngBq1eEt2qbfoONJWYry56KGiV++CHzFw+4Xp41WnrZmRpnnLDDgcE3uAzL8KcjEzsd8+TJ+aKaVBmFjF0AXs=
Linked from:
- Chad Wahlbrink @Chad2023-09-22 16:40:49.295Z
Hey @Lynn_Graber!
Can you give me an example of what kind of session naming scheme you are using? What kind of suffix do you need to remove?- LLynn Graber @Lynn_Graber
Aight, so I get ALOT of songs a month that come in formatted Artist Name_Song Name. My final mixes need to be named Song Name_FULL, Song Name_INST, Song Name_TV. Easy enough to do a save as in PT, but kinda a pain to edit the name. The main session folder name needs to stay as the original format. Hope this makes sense.
Also, as a bonus, wondering if there is a quick way to rename the bounced files folder to the main session folder name after all my mixes and stems are bounced. That is then the folder I can collect via a smart folder and deliver. Could definitely be its own button through finder.
I realize now, my title was a little confusing. Sorry.
Chad Wahlbrink @Chad2023-09-22 19:33:49.446Z
@Lynn_Graber, your bonus question. This script will rename the bounced files folder based on the current session Folder Name.
// Get the session path from the SDK const sessionPath = sf.app.proTools.getSessionPath().sessionPath.replace(/:/g, '/').split('/').slice(1,-1).join('/'); // Get Session Folder Name const sessionName = sf.file.getFileInfo({path:`${sessionPath}`}).fileInfo.name sf.system.exec({ commandLine: ` mv "${sessionPath}/Bounced Files" "${sessionPath}/${sessionName}" `});
- LLynn Graber @Lynn_Graber
Man, this one looks like its doing something, but it is not changing the Bounce Files folder name.
- LLynn Graber @Lynn_Graber
I see there is a command line portion in this script, could OSX be blocking this?
Chad Wahlbrink @Chad2023-09-23 13:21:02.624Z
Hey @Lynn_Graber,
It's possible that there is a permissions issue. Note – that this script only works if the session is actively open.
// Get the session path from the SDK const sessionPath = sf.app.proTools.getSessionPath().sessionPath.replace(/:/g, '/').split('/').slice(1,-1).join('/'); // Get Session Folder Name const sessionName = sf.file.getFileInfo({path:`${sessionPath}`}).fileInfo.name sf.file.directoryMove({sourcePath: `${sessionPath}/Bounced Files`, destinationPath: `${sessionPath}/${sessionName}`})
You could try this slightly tweaked version using SoundFlow's native file actions.
If this continues to fail, try this and let me know the values of the two log actions.// Get the session path from the SDK const sessionPath = sf.app.proTools.getSessionPath().sessionPath.replace(/:/g, '/').split('/').slice(1,-1).join('/'); // Get Session Folder Name const sessionName = sf.file.getFileInfo({path:`${sessionPath}`}).fileInfo.name log(sessionName) log(sessionPath)
- LLynn Graber @Lynn_Graber
With that first one in your post, now I at least get an error.
- In reply toChad⬆:LLynn Graber @Lynn_Graber
Is this what you need from the log file?
25.09.2023 10:39:48.73 <info> [Backend]: [SF_FIREBASE_WS]: Received 44 bytes. Total received: 8021 25.09.2023 10:39:57.26 <info> [Backend]: #StreamDeck: deck-button-click -> Rename BNC Folder 25.09.2023 10:39:57.26 <info> [Backend]: >> Command: Rename BNC Folder [user:default:clmv3kz790008yf10aa0qrnff] 25.09.2023 10:39:57.29 <info> [Backend]: [ProToolsController] Response body received: { "session_name":"Chefboy RT_Good Medicine" } 25.09.2023 10:39:57.44 <info> [Backend]: [ProToolsController] Response body received: { "session_path": { "info": { "is_online":false }, "path":"/Users/lynngraber/Desktop/0000 WavMaker Mixes/Chefboy RT_Good Medicine/Chefboy RT_Good Medicine.ptx" } } 25.09.2023 10:39:57.44 <info> [Backend]: [LOG] Chefboy RT_Good Medicine 25.09.2023 10:39:57.44 <info> [Backend]: [LOG] /Users/lynngraber/Desktop/0000 WavMaker Mixes/Chefboy RT_Good Medicine 25.09.2023 10:39:57.44 <info> [Backend]: << Command: Rename BNC Folder [user:default:clmv3kz790008yf10aa0qrnff] 25.09.2023 10:40:06.10 <info> [Backend]: #StreamDeck: deck-button-click -> Rename BNC Folder 25.09.2023 10:40:06.10 <info> [Backend]: >> Command: Rename BNC Folder [user:default:clmv3kz790008yf10aa0qrnff] 25.09.2023 10:40:06.13 <info> [Backend]: [ProToolsController] Response body received: { "session_name":"Chefboy RT_Good Medicine" } 25.09.2023 10:40:06.24 <info> [Backend]: [ProToolsController] Response body received: { "session_path": { "info": { "is_online":false }, "path":"/Users/lynngraber/Desktop/0000 WavMaker Mixes/Chefboy RT_Good Medicine/Chefboy RT_Good Medicine.ptx" } } 25.09.2023 10:40:06.24 <info> [Backend]: [LOG] Chefboy RT_Good Medicine 25.09.2023 10:40:06.24 <info> [Backend]: [LOG] /Users/lynngraber/Desktop/0000 WavMaker Mixes/Chefboy RT_Good Medicine << Command: Rename BNC Folder [user:default:clmv3kz790008yf10aa0qrnff] 25.09.2023 10:40:33.67 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive 25.09.2023 10:41:18.68 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive 25.09.2023 10:42:03.68 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive 25.09.2023 10:42:48.69 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive 25.09.2023 10:43:33.69 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive 25.09.2023 10:43:56.21 <info> [Backend]: Cancel all commands invoked on engine... 25.09.2023 10:44:18.70 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive 25.09.2023 10:45:03.70 <info> [Backend]: [SF_FIREBASE_WS]: Sending keep-alive
- LLynn Graber @Lynn_Graber
Here are is a screenshot of what happens trying to run each of these scripts. The original is Script 1, these last two are 2 and 3
https://www.dropbox.com/scl/fo/yqr71izlx9abn79w5vca5/h?rlkey=xseltk6qdyk1cxp0n408ck6hb&dl=0
The original one seems like its actually doing something somewhere, but obviously you can see no change in the session folder.
Chad Wahlbrink @Chad2023-09-25 18:51:55.268Z
Thanks, @Lynn_Graber! I’ll look into this in the next day or two.
Chad Wahlbrink @Chad2023-09-26 16:20:57.120Z
@Lynn_Graber - can I get you to check these permissions settings in System Preferences > Security & Privacy > Files and Folders > SoundFlow
If there are "unchecked" boxes here, then check them, OR delete all of them using the "-" button, and try running the scripts again.
You should be prompted with something like this:- LLynn Graber @Lynn_Graber
Bam. That did it dude. Happy dance.
- LIn reply toLynn_Graber⬆:Lynn Graber @Lynn_Graber
The script I posted above does get the job done of adding _FULL as a suffix, but I cant figure out how to remove the artists name and just leave the song name.
Chad Wahlbrink @Chad2023-09-22 18:47:00.487Z
Thanks @Lynn_Graber, can you give me an example name including a "version number" so I can see how you are trying to strip that out?
Chad Wahlbrink @Chad2023-09-22 18:47:59.934Z
Or is that part working already?
- LLynn Graber @Lynn_Graber
Sent you a screen recording via email, I guess we cant upload videos here?
- In reply toChad⬆:LLynn Graber @Lynn_Graber
I am not doing and version numbers. Just renaming the session. Sorry my original post was in haste as I was headed out the door and probably didnt make alot of sense.
- In reply toLynn_Graber⬆:Chad Wahlbrink @Chad2023-09-22 18:52:46.055Z
@Lynn_Graber, this version of the script will strip out "Artist Name" from the Session Name as long as there is only one "_" character in the name.
Also adding support for Pro Tools 2023.09 since they just changed the name of "Save As..." to "Save Session As..." in the Pro Tools File Menu.
if (!sf.ui.proTools.isRunning) throw `Pro Tools is not running`; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); // Get Pro Tools Version as Number function getProToolsVerion() { const versionNumberArray = sf.ui.proTools.appVersion.split('.'); let [year, month, increment] = versionNumberArray; // add a leading 0 if less than 10 month = Number(month) < 10 ? "0" + month.slice(-1) : month; // add a leading 0 if less than 10, but only monitor increments up to 10 increment = Number(increment) < 10 ? "0" + increment.slice(-1) : increment.slice(-2); return Number(year + month + increment); } //Get PT version Number const ptVersion = getProToolsVerion(); // 2023.06 to 2023.09 support const saveAsmenuPath = ptVersion >= 230900 ? ["File", "Save Session As..."] : ["File", "Save As..."]; function saveSessionAs(newSessionName) { sf.ui.proTools.menuClick({ menuPath: saveAsmenuPath }); const saveAsWin = sf.ui.proTools.windows.whoseTitle.is('Save').first.elementWaitFor({ waitType: "Appear" }, 'Save as Window Didn\'t Open.').element; saveAsWin.textFields.first.value.value = newSessionName; saveAsWin.buttons.whoseTitle.is('Save').first.elementClick(); saveAsWin.elementWaitFor({ waitType: "Disappear" }, 'Save as Window Didn\'t Close.'); } function getNewSessionName() { let newSessionName; const sessionPath = sf.ui.proTools.mainWindow.sessionPath; const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.'); let sessionVersion = sessionName.match(/\d+$/) if (!sessionVersion) { newSessionName = sessionName.split('_')[1] + "_FULL" return newSessionName; }; let versionNumber = +sessionVersion[0]; let cleanSessionName = sessionName.split(/\d+$/)[0]; let newVersion = ++versionNumber <= 9 ? "0" + versionNumber : versionNumber return cleanSessionName + newVersion }; let newName = getNewSessionName(); saveSessionAs(newName)
Chad Wahlbrink @Chad2023-09-22 18:54:18.396Z
The only real change to your code was in line 45. I'm using
sessionName.split('_')[1]
to separate the session name by the "_" character and then use the second half in the new name, in this case, the song name.
- LIn reply toLynn_Graber⬆:Lynn Graber @Lynn_Graber
This is great dude. Thank you! Watching that video now.