Copy Session Name to clipboard
Hi All,
I've seen a popular way of fetching the session name to use as a variable:
sf.ui.proTools.appActivateMainWindow();
var sessionPath = sf.ui.proTools.mainWindow.sessionPath;
var sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
Is there a way of popping this variable into the clipboard so I can paste it elsewhere? I'd like to be able to use it in the Bounce Window, or the Batch Rename window etc.
I have seen scripts which populate the relative text boxes with that info directly, but I'd like the grab it from the clipboard and paste it, if possible.
I find javascript very challenging, so if you could bear that in mind in your answer that'd be amazing! :D
Thanks all
Trystan
- Raphael Sepulveda @raphaelsepulveda2023-11-02 20:14:33.913Z
Hey @T_Francis, this can be easily achieved with this short script:
// Grab session name and copy it to the clipboard sf.clipboard.setText({ text: sf.app.proTools.getSessionName().sessionName });
As you know, there is a more efficient way to populate text fields without depending on the clipboard as a middleman, but I know scripting can be challenging, so this will work just fine.
Whenever you feel ready to take that next step, just post your script and we'll upgrade it for ya!
- TIn reply toT_Francis⬆:T Francis @T_Francis
raphaelsepulveda, that is immensely helpful (and understanding!). Thankyou - you may be hearing more from me 😁
- TT Francis @T_Francis
Hi there,
so I've implemented this, but it appears to be taking the folder name, rather than the session name.
I'm using the above script verbatim on a button on the streamdeck, do I need to implement it in a different way?
Thanks very much!
Trystan
Raphael Sepulveda @raphaelsepulveda2023-11-13 18:24:28.593Z
Mmm.. I'm not seeing that here, but let's try a few things.
A slight adjustment first:// Grab session name and copy it to the clipboard sf.clipboard.setText({ text: sf.app.proTools.invalidate().getSessionName().sessionName });
If that doesn't work, let's fall back to the old method of fetching the session name:
// Get session name const sessionName = sf.ui.proTools.mainWindow.sessionPath .split("/").slice(-1).join() // Get file name .split(".")[0]; // Get session name // Copy it to the clipboard sf.clipboard.setText({ text: sessionName });
- TIn reply toT_Francis⬆:T Francis @T_Francis
Hi, thanks for your quick response!
So the "fallback" method works better; the adjustment method did the same thing for me, continuing to take the folder name.
There's one issue now, it's the format of my filename. I have a full-stop earlier in the title (the naming format is: XXX 0m00 v1.00 cxxxx Title.ptx) so it's currently binning everything after the initial full-stop. Can that format be shifted to the 2nd full-stop so it just bins the .ptx?
Thanks again!
Trystan
Raphael Sepulveda @raphaelsepulveda2023-11-14 17:40:55.251Z
Sure thing!
// Get session name const sessionName = sf.ui.proTools.mainWindow.sessionPath .split("/").slice(-1).join() // Get file name .match(/(.*).ptx$/)[1] // Get session name // // Copy it to the clipboard sf.clipboard.setText({ text: sessionName });