Hey all,
I'm loving what I'm starting to be able to do with Soundflow - and although I'm a total Java newbie and I'm very much bodging my way through it with bits of other scripts and macro's, I'm starting to get some great results.
I've built a script that uses a little of @Andrew_Scheps 'Increment New Playlist' script and modifies it to apply to a duplicated track. It's working ok, although may be a little clunky. What I'm struggling with is how to get it to add a number if one doesn't exist already.
So for example: "Fuzz Gtr 1" will be duplicated and the new name will be "Fuzz Gtr 2". However, if the original track was called "Fuzz Gtr" the script can't update the number. How could I have it check if a number exists, and if not, add it? Any help gratefully received!
Cheers,
Tim
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.trackDuplicateSelected({
duplicateActivePlaylist: false,
duplicateAlternatePlaylists: false,
duplicateAutomation: false,
});
//Remove .dup1 from existing name
var oldTrackName = sf.ui.proTools.selectedTrackNames[0];
var oldTrackName = oldTrackName.split('.').slice(0, -1).join('.');
//Get and Increment Last Number
function getAndIncrementLastNumber(str) {
return str.replace(/\d+$/, function (s) {
return ++s;
});
}
//Variable for new track name
var newTrackName = getAndIncrementLastNumber(oldTrackName);
sf.ui.proTools.selectedTrack.trackOpenRenameDialog({
renameAllSelectedTracks: false,
});
//Wait for Rename Track window to appear
sf.ui.proTools.windows.first.elementWaitFor({ waitType: "Appear", });
sf.ui.proTools.windows.first.textFields.whoseTitle.is('').first.elementSetTextFieldWithAreaValue
({ value: newTrackName });
//Click OK in Rename Track window
sf.ui.proTools.windows.first.buttons.whoseTitle.is('OK').first.elementClick();
Linked from:
- Christian Scheuer @chrscheuer2020-10-20 12:43:56.113Z
I use this in my own workflow:
var numberOfDups = Number(prompt('How many duplicates?', '1')); var originalTrackName = sf.ui.proTools.selectedTrackNames[0]; sf.ui.proTools.trackDuplicateSelected({ duplicateActivePlaylist: false, duplicateAlternatePlaylists: false, duplicateAutomation: false, duplicateGroupAssignments: true, duplicateInserts: true, duplicateSends: true, insertAfterLastSelectedTrack: true, numberOfDuplicates: numberOfDups }); sf.ui.proTools.trackSelectByName({ names: [originalTrackName], deselectOthers: false }); sf.ui.proTools.selectedTrack.trackBulkRenameNumerical();
- TTJ Allen @TJ_Allen
That's amazing - thanks Christian. So much sleeker than my clunky version!
- TTJ Allen @TJ_Allen
This is working perfectly on all tracks except Instrument Tracks - is that a limitation of BulkRenameNumerical?
It's logging:
Could not bulk rename tracks (Numerical Duplicates: Line 17)
Could not open Track Rename Dialog
Could not right-click Track's Title Button
Popup menu was not found
Popup window was not found after waiting 2000 msChristian Scheuer @chrscheuer2020-10-20 13:46:03.142Z
Yea that sounds like a limitation... I've logged a bug report for this.
- TTJ Allen @TJ_Allen
Thanks Christian,
It's really amazing what Soundflow can do.
- In reply tochrscheuer⬆:AAndrew Downes @Andrew_Downes
Hi There
I would love to be able to apply this to Playlists. I can do it so long as there are numbers as a suffix in the track name, but haven't been able to add a nimber if there isn't one
ThanksChristian Scheuer @chrscheuer2020-10-21 10:05:45.829Z
Hi Andrew,
Let's have that discussion in a separate thread :) It makes it easier for us to check which questions have been answered. I think the code needed for new playlists is quite different.
- SSteve Bissinger @sbiss2021-02-23 00:40:39.334Z
When I convert this script to a template I get an error: Expected boolean but got string - line 14. What I am doing wrong here?
const {
activePlaylist,
alternatePlaylists,
automation,
inserts,
sends,
groupAssignments,
afterLastSelectedTrack,
} = event.propsvar numberOfDups = Number(prompt('How many duplicates?', '1'));
var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
sf.ui.proTools.trackDuplicateSelected({
duplicateActivePlaylist: activePlaylist,
duplicateAlternatePlaylists: alternatePlaylists,
duplicateAutomation: automation,
duplicateGroupAssignments: groupAssignments,
duplicateInserts: inserts,
duplicateSends: sends,
insertAfterLastSelectedTrack: afterLastSelectedTrack,
numberOfDuplicates: numberOfDups
});sf.ui.proTools.trackSelectByName({ names: [originalTrackName], deselectOthers: false });
sf.ui.proTools.selectedTrack.trackBulkRenameNumerical();- SSteve Bissinger @sbiss2021-02-23 00:43:06.572Z
The enum members for each property are "true" and "false".
Raphael Sepulveda @raphaelsepulveda2021-02-23 01:11:19.203Z
For this to work in a template you’ll have to use boolean when creating the props instead of User enums. Booleans will be displayed as “Yes” or “No” to the user in the template, but the value passed will be true or false.
- SSteve Bissinger @sbiss2021-02-23 02:41:58.214Z
Thats was an easy fix. Thanks!
- SSteve Bissinger @sbiss2021-02-23 03:04:42.548Z
One last issue. With folder tracks we now have a checkbox for "All Member Tracks", which is not implemented in the above code. I tried a few things, but couldn't bring up anything that looked correct for this - at least as Christian has coded it. I know other ways to do this, but is there a way to add this in this code?
Raphael Sepulveda @raphaelsepulveda2021-02-23 03:27:08.659Z
Unfortunately no. :( The
.trackDuplicateSelected()
method is missing that property currently, so @chrscheuer would have to update it.- SSteve Bissinger @sbiss2021-02-23 03:36:58.784Z
Got it. Maybe he can do that when he has a free second :)
Christian Scheuer @chrscheuer2021-02-23 10:29:06.281Z
Hey guys. Please log this in Alpha/Beta Ideas so I don't forget it after the 4.2 release :)
- SSteve Bissinger @sbiss2021-02-23 17:08:07.082Z
Done!