Hi,
can this handy script by @chrscheuer and @Fokke be modified to work for the duplication of multiple tracks and single tracks?
sf.ui.proTools.trackDuplicateSelected({
duplicateActivePlaylist: false,
duplicateAlternatePlaylists: false,
duplicateAutomation: false,
duplicateGroupAssignments: true,
duplicateInserts: true,
duplicateSends: true,
insertAfterLastSelectedTrack: true,
numberOfDuplicates: 1
})
sf.ui.proTools.selectedTrack.trackRename({
renameFunction: function (name) {
//This function gets called after the Rename track dialog is open
//the argument 'name' holds the existing name, eg. "Audio 4.dup1"
//We're supposed to eventually return the target name we want from this function.
var grps = name.match(/^([^\d]*)( ?)(\d*)\.dup.*/);;
//This regular expression matches a string containing of the following groups (each group is in parentheses)
//Group 1 - syntax: ([^\d]*) - meaning: Match any number (*) of characters that are NOT digits ([^\d]). This will match "Audio"
//Group 2 - syntax: ( ?) - meaning: Match either 0 or 1 (?) space character
//Group 3 - syntax: (\d*) - meaning: Match any number (*) of characters that are digits (\d). This will match "4".
//After last group- syntax: \.dup.* - meaning: Match a dot (\.), the text "dup", and then ANY character (.), any number of times (*)
//Save out the groups, baseName, space, numName
var baseName = grps[1];
var space = grps[2];
var numName = grps[3];
//If you didn't have a number, by default we want a space ' ' before our new #2 track
if (numName == "") space = " ";
//Create the new number. If there wasn't one, we'll default to 2, if there was one, convert our string to a number, and add 1 to that
var newNum = numName == "" ? 2 : Number(numName) + 1;
//Return the new name, a combination of the base name "Audio", a space or not " ", and the new number (converted to a string to make sure we don't mix up types)
return baseName + space + (newNum + '');
}
});
- Christian Scheuer @chrscheuer2020-11-11 17:12:46.504Z
Can you elaborate on which part doesn't work as expected when duplicating multiple tracks?
The duplicate part should work just fine if you have more than one track selected. But the renaming process would likely have to be different. The above function just renames numerically. If you're duplicating a group of tracks, you'd likely want the renaming to occur with a different numbering scheme.
To help you with that, we'd need some examples of what the before/after should look like.- JJascha Viehl @Jascha_Viehl
Hi Christian,
I've managed to get a workaround that already works in combination with another function:
duplicateActivePlaylist: false, duplicateAlternatePlaylists: false, duplicateAutomation: false, duplicateGroupAssignments: true, duplicateInserts: true, duplicateSends: true, insertAfterLastSelectedTrack: true, numberOfDuplicates: 1 }) sf.keyboard.press({ keys: "shift+p", }); sf.ui.proTools.selectedTrack.trackBulkRenameNumerical();
I would only need to replace the function
sf.keyboard.press()
with more reliable UI automation.
Didn't find how to extend the selection of tracks one to the top.Btw. thank you for the many responses.
I'm only beginning to learn java script.Christian Scheuer @chrscheuer2020-11-11 19:01:48.031Z
Although you can also use SoundFlow's track management actions to do this, I believe Pro Tools recently added a menu item to expand your track selection towards the top. I recall it as being somewhere in the Edit menu in a sub menu.
You can automate that with a "Click Menu Item" action in a macro and convert it to Javascript and put it in instead of the "shift+p" :)
- RIn reply toJascha_Viehl⬆:Robbie Grunwald @Robbie_Grunwald
Hi there... Im a new user of soundflow and am trying to write some of my first scripts. This script does some similar things to what I am trying to do. I am trying to rename a playlist where I update the name so that it contains todays date. So basically I want to read in the name of the playlist which is the name of the song followed by a hyphen and then the date in yyyymmdd format. then I want to update the date to todays date. I dont really understand the syntax for reading in the string in groups as shown in this script.
Basically the format of the name of my playlist is 'Song Title - 20210625'. so in my script I want to read in that name and change the date to todays date so I would have to change the groups in this script accordingly.
How do I do that.
Christian Scheuer @chrscheuer2021-06-28 21:57:44.740Z
Hi Robbie.
This should get you in the right direction - this will rename the current track, strip everything after the hyphen and replace it with the current date in YYYYMMDD format.
function today() { var d = new Date(); return d.getFullYear().toString().padStart(4, '0') + (d.getMonth() + 1).toString().padStart(2, '0') + d.getDate().toString().padStart(2, '0'); } sf.ui.proTools.selectedTrack.trackRename({ renameFunction: function (oldName) { //Take what's before the hyphen: let baseName = oldName.split('-')[0].trim(); //Return that, a hyphen (surrounded by spaces) followed by today's date return baseName + ' - ' + today(); } });
Please note, that it's often better to open new questions and link to old questions, rather than appending new questions to old threads, as we use the status of a thread (for example, this is solved) to understand where to allocate resources :)