new playlist and name the track with the name of current playlist but with incremental numbering
Can anyone help with this?
Create a new playlist with the next numerical number as the suffix.
For example, the current playlist is: BEST SONG EVER_MIX_V1 and I'd like a new playlist with the track now named BEST SONG EVER_MIX_V2
Thank you!!!
- AAndrew Downes @Andrew_Downes
Hi There
This is what I use for that, or at least for Duplicating Playlists. I f you want a New Playlist replace Duplicate in the menu path wth Newfunction doForAllSelectedTracks(action) { var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames; try { sf.ui.proTools.selectedTrackHeaders.forEach(track => { track.trackSelect(); action(track); }); } finally { sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames }); } } function trackFunc() { //Insert your code here sf.ui.proTools.appActivateMainWindow(); if (!sf.ui.proTools.selectedTrack.normalizedTrackName.match(/\d+$/)) { sf.ui.proTools.selectedTrack.trackRename({ renameFunction: n => n + ' t1', }); } //Get the current track/playlist name var oldPlaylistName = sf.ui.proTools.selectedTrackNames[0]; //Duplicate selected track playlist sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is('Playlist selector').first.popupMenuSelect({ menuPath: ["Duplicate..."], }); //Wait for Duplicate Playlist window to appear sf.ui.proTools.confirmationDialog.elementWaitFor({waitType: "Appear",}); //Click OK in Duplicate Playlist window sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('OK').first.elementClick(); //Wait for Duplicate Playlist window to disappear sf.ui.proTools.confirmationDialog.elementWaitFor({waitType: "Disappear",}); //Get and Increment Last Number function getAndIncrementLastNumber(str) { return str.replace(/\d+$/, function (s) { return ++s; }); } //Variable for new clip name var newPlaylistName = getAndIncrementLastNumber(oldPlaylistName); //Rename Track with Old Name + Incrimented value sf.ui.proTools.selectedTrack.trackRename({ newName: newPlaylistName, }); } doForAllSelectedTracks(trackFunc);
- TThomas Gloor @Thomas_Gloor
Hey @Andrew_Downes
Thank you for a great script! I was wondering if it would be possible to store the "increment" in a variable. Would you know?
Basically, I'd like to get what the last number was, increment it by one and store the n+1 in a variable.
Thanks!
- AAndrew Downes @Andrew_Downes
Hi Thomas
I imagine it would be possible, as it seems most things are in here, but its way outside my knowledge of scripting. There is bound to be someone in the forums who can help though.- TThomas Gloor @Thomas_Gloor
Thank you for your answer Andrew. I think i found a lead, will post if I find it!
- JIn reply toJonathan_Grossman⬆:Jonathan Grossman @Jonathan_Grossman
Thanks Andrew!
I'm getting an error on line 35. Any ideas?
10.02.2022 18:27:05.05 [Backend]: Logging error in action (01) WaitForElementAction: Element was not found or removed after waiting 2000 ms
10.02.2022 18:27:05.61 [Backend]: !! Command Error: NEW PLAYLIST V+ [user:ck99zpoez000h6e10rjx8vg5g:ckzhsbddb0000bx102ob52qc3]:
Element was not found or removed after waiting 2000 ms (NEW PLAYLIST V+: Line 35)<< Command: NEW PLAYLIST V+ [user:ck99zpoez000h6e10rjx8vg5g:ckzhsbddb0000bx102ob52qc3]
- AIn reply toJonathan_Grossman⬆:Andrew Downes @Andrew_Downes
I am not getting any errors here.
The is a prefence in the editing tab in the tracks part 'Supress Name Dialog When Creating New Playlists' theis should be unticked.- JJonathan Grossman @Jonathan_Grossman
Andrew - can we adjust this script so instead of "t1" it says "_V1" and goes incremental with that suffix?
- AAndrew Downes @Andrew_Downes
Of course you can!
- JIn reply toJonathan_Grossman⬆:Jonathan Grossman @Jonathan_Grossman
yep - that fixed it. Thanks Andrew!