Pro Tools, copy name from region to track
Hi.
Is there a way to mark a region, and then have the name of that region be copied to the name of the corresponding track? I can't figure out how to build such a macro.
Linked from:
- Raphael Sepulveda @raphaelsepulveda2020-12-09 17:40:45.323Z
Hey Tor!
The following script will grab the name of the selected clip and rename the selected track.
Let me know if that works for ya!const clipRenameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first; sf.ui.proTools.appActivateMainWindow(); // Get name from clip sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] }); clipRenameWin.elementWaitFor({ waitType: "Appear", }, 'Make sure a clip is selected'); let clipName = clipRenameWin.groups.whoseTitle.is('Name').first.textFields.first.value.invalidate().value; clipRenameWin.buttons.whoseTitle.is('OK').first.elementClick(); clipRenameWin.elementWaitFor({ waitType: "Disappear", }); // Rename selected track sf.ui.proTools.selectedTrack.trackRename({ newName: clipName });
- TIn reply toTor_Bach_Kristensen⬆:Tor Bach Kristensen @Tor_Bach_Kristensen
Yeah, it kind of works. Though it takes the name in the clip list, preferably it would be the name from any region marked in the arranged window :) And getting this error most of the times:
Could not complete the Rename Selected Audio Clips command because Assertion in "/Volumes/Development/protools/release/2020/r3/ProTools/NewFileLibs/AFnd/Stems/AFnd_StemFormat.cpp", line 722.
- In reply toTor_Bach_Kristensen⬆:Raphael Sepulveda @raphaelsepulveda2020-12-10 16:28:30.495Z
Oh no!
Maybe I'm misunderstanding something. Could you explain in a bit more detail what you would like the script to do? What do you mean exactly when you say "mark a region"?
- MIn reply toTor_Bach_Kristensen⬆:Michael Bouska @Michael_Bouska
Im getting this error too. I think its because pro tools is trying to rename the Clip AND disk file. I think if you select "Name clip Only" in the clip rename dialog window, you won't get the error, but I have no idea how to add that to this script code haha
Dustin Harris @Dustin_Harris
Try changing
clipRenameWin.buttons.whoseTitle.is('OK').first.elementClick();
To
clipRenameWin.buttons.whoseTitle.is('cancel').first.elementClick();
And see if that fixes it. I’m on my phone at the moment so I can look into multiple tracks later on (unless Raphael beats me to it)
Raphael Sepulveda @raphaelsepulveda2021-02-28 15:38:32.517Z
Thanks, @Dustin_Harris ! I’m away from my studio this weekend so feel free to do so!
Dustin Harris @Dustin_Harris
Nice dude, enjoy! (And challenge accepted)
- MIn reply toTor_Bach_Kristensen⬆:Michael Bouska @Michael_Bouska
Also, if this code could be made to rename multiple selected tracks at once that would be amazing!
Dustin Harris @Dustin_Harris
Try this and let me know how it goes:
const clearFind = () => sf.keyboard.press({ keys: "cmd+shift+d", }, `error in clearFind()`); function getCurrentClipName() { //This gets the current region name in Pro Tools const clipNameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first try { clearFind(); sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] }); clipNameWin.elementWaitFor({}, `could not find rename window`); let currentClipName = clipNameWin.groups.whoseTitle.is('Name').first.textFields.first.value.invalidate().value; clipNameWin.buttons.whoseTitle.is('Cancel').first.elementClick({}, `could not click Rename window: cancel button`); return currentClipName } catch (err) { throw `error in getCurrentClipNameWin(): ${err}` } } /** * @param {string} clipName */ function renameTrackFromClipName(clipName) { sf.ui.proTools.selectedTrack.trackRename({ newName: clipName }, `could not rename track to "${clipName}"`); } function main() { try { sf.ui.proTools.appActivateMainWindow(); const { selectionStart, selectionEnd } = sf.ui.proTools.selectionGetInSamples(); const selectedTracks = sf.ui.proTools.selectedTrackNames; selectedTracks.forEach(track => { sf.ui.proTools.trackSelectByName({ names: [track], deselectOthers: true }, `error selecting track: ${track}`); sf.ui.proTools.selectionSetInSamples({ selectionStart, selectionEnd }); sf.keyboard.press({ keys: 'left' }, `error in keyboard.press: left`); //update pro tools menu ui const clipName = getCurrentClipName(); renameTrackFromClipName(clipName); }) sf.ui.proTools.trackSelectByName({ names: selectedTracks }); sf.ui.proTools.selectionSetInSamples({ selectionStart, selectionEnd }); } catch (err) { throw `error in main(): ${err}` } alert('Done'); } main();
- MMichael Bouska @Michael_Bouska
hot damn! This works like a charm!! THANK YOU!
Dustin Harris @Dustin_Harris
My pleasure! Useful one to make!
- In reply toDustin_Harris⬆:
Raphael Sepulveda @raphaelsepulveda2021-03-01 03:22:13.684Z
That's awesome! Love the error handling and clever use of destructuring to get the selection values!
Dustin Harris @Dustin_Harris
It was a game changer to realize I could shorten
{name: name,}
to just{name,}
:)
- In reply toTor_Bach_Kristensen⬆:Henrik Skram @Henrik_Skram
Hi, can´t get this one to work, I get this error:
08.06.2022 11:41:34.30 [Backend]: JavaScript error with InnerException: null
!! Command Error: Name track from clip [user:ckzbejwdr0001wz10j2ba2kxx:cl45e7awh0000qu1089bq93ur]:
TypeError: Cannot read property 'trackName' of undefined
(Name track from clip line 84)Any pointers would be greatly appreciated!
Chris Shaw @Chris_Shaw2022-06-08 18:16:41.487Z
If you're running the latest version of PT (2022.5 at this time) be sure you are running the latest version of SoundFlow (5.1.5). You may have to install it manually from here:
Chris Shaw @Chris_Shaw2022-06-08 18:17:03.892Z
If this doesn't work let us know here.
- AIn reply toTor_Bach_Kristensen⬆:Alexis Cuadrado @Alexis_Cuadrado
Hi there,
Spanking brand new to SF, so I'm probably doing something wrong!
Tried to run this script (created a package, created a script, assigned a key command), and it didn't work.
Getting this error message:08.01.2023 10:47:15.22 [Backend]: !! Command Error: Rename Track from Clip Name [user:clcnjncgs0000jy10v0l5dj76:clcnjo2gi0001jy10fzqp59jg]:
error in main(): Error: KeyboardPressAction
(Rename Track from Clip Name line 39)Thank you so much in advance for any help
- TTor Bach Kristensen @Tor_Bach_Kristensen
Same here, don't know why...
- TTor Bach Kristensen @Tor_Bach_Kristensen
@Dustin_Harris can you help us out? This is way beyond my skills :)
Dustin Harris @Dustin_Harris
Oh wow! Looks like the sf.keyboard.press has become case-sensitive!
try replacing
sf.keyboard.press({ keys: 'Left' }); //update pro tools menu ui
with
sf.keyboard.press({ keys: 'left' }); //update pro tools menu ui
I'm going to update the whole script. brb.
- In reply toTor_Bach_Kristensen⬆:
Dustin Harris @Dustin_Harris
I've updated the script in the post here:
- TTor Bach Kristensen @Tor_Bach_Kristensen
Same error here as before :)
- TTor Bach Kristensen @Tor_Bach_Kristensen
Error report:
23.06.2023 15:56:31.20 [Backend]: #StreamDeck: KeyDown (3,4) -> Rename From Region
23.06.2023 15:56:31.20 [Backend]: >> Command: Rename From Region [user:default:clj8j2qdf0001bk10qzr3spiu]
23.06.2023 15:56:31.20 [Backend]: Checking for running apps with bundle 'com.avid.ProTools'
23.06.2023 15:56:31.20 [Backend]: NSArray.ArrayFromHandle count = 1
23.06.2023 15:56:31.28 [Backend]: Mouse current pos is: (1260,819091796875, 238,03866577148438)
Clicking with mouse here: (12, 62)23.06.2023 15:56:31.29 [Backend]: Moving mouse back to: (1260,819091796875, 238,03866577148438)
23.06.2023 15:56:31.29 [Backend]: Position is now: (1260,819091796875, 238,03866577148438)
23.06.2023 15:56:31.75 [Backend]: Succesfully set selection to: MainCounter: Sel Start: 0 Sel End: 7931279 Sel Length:
23.06.2023 15:56:31.75 [Backend]: Logging error in action (01) KeyboardPressAction: Key 'Left' wasn't recognized.
23.06.2023 15:56:31.75 [Backend]: JavaScript error with InnerException: null
!! Command Error: Rename From Region [user:default:clj8j2qdf0001bk10qzr3spiu]:
error in main(): Error: KeyboardPressAction
(Rename From Region line 39)Dustin Harris @Dustin_Harris
looks like there is still an uppercase 'L' in 'left'?
- TTor Bach Kristensen @Tor_Bach_Kristensen
I have it working now, I didn't copy paste it correctly. Sorry! This is awesome thanx!!!!!
Dustin Harris @Dustin_Harris
Awesome! Glad it's working now!
- In reply toDustin_Harris⬆:TTor Bach Kristensen @Tor_Bach_Kristensen
I have it working now, I didn't copy paste it correctly. Sorry! This is awesome thanx!!!!!