First selected clip name to track name
Hello @Tom_Davis. and @Matt_Friedman
this will copy the first clip name of a selection, including multiple tracks,
cleaning from the first "." to track name.
this "Audio 4_110.L" to ""Audio 4_110"
if track name exists it will add ".1" at the end of the name
let me know if this is it.
// Fix if track name exists
function checkTrackDuplicate(trackName) {
const trackNameExists = sf.app.proTools.tracks.invalidate().allItems.find(tn => tn.name === trackName)
if (trackNameExists && trackNameExists.name) {
return trackName + ".1"
} else {
return trackName
};
};
// GROUP CLIP NAMES ARE ERRONEOUS ON track widths more than mono!!!
function clipNameToTrackName() {
const clipInfo = sf.app.proTools.getSelectedClipInfo().clips
let trackInfoFilter = []
let obj = {}
for (let i = 0; i < clipInfo.length; i++) {
const trackName = clipInfo[i]["TrackName"];
const clipName = clipInfo[i]["ClipName"];
const cleanClipName = clipName && clipName.split(".").slice(0, 1).join()
let isClip = !clipName.startsWith("(fade ") && !clipName.endsWith(" fade)")
if (!obj[trackName] && isClip) {
obj[trackName] = cleanClipName
trackInfoFilter.push({ trackName, clipName: cleanClipName })
};
};
trackInfoFilter.forEach(tr => {
sf.app.proTools.renameTrack({
oldName: tr.trackName,
newName: tr.trackName !== tr.clipName ? checkTrackDuplicate(tr.clipName) : tr.trackName,
onError: "Continue"
});
})
};
clipNameToTrackName();
- MMatt Friedman @Matt_Friedman
Thanks Samuel. Looks brilliant. I was playing with this on my own but got frustrated and gave up when the SDK API was returning .L in the clip name but I see you found a good way to clean them up!
Also, why haven't they made you a Soundflow Ambassador yet????
- TIn reply tosamuel_henriques⬆:Tom Davis @Tom_Davis
WOW! Thank you Samuel and Matt! Can't wait to try this out!
Appreciate you both!
td
- MIn reply tosamuel_henriques⬆:Matt Friedman @Matt_Friedman
One little update I'd suggest is to change this line so that it handles clip names that contain periods. So a clip name like "Audio File.tk_10.L" becomes "Audio File.tk_10"
So changing this:
const cleanClipName = clipName && clipName.split(".").slice(0, 1).join()
to this:
const cleanClipName = clipName && clipName.split(".").slice(0, -1).join(".")
- MIn reply tosamuel_henriques⬆:Matt Friedman @Matt_Friedman
I actually updated the
cleanClipName
code a bit more. The current implementations will skip over Mono clips.But the following below won't, as this will remove any suffix we'd get from a clip name (.L, .R, .LFE, .Ls, .Rss, etc.). This way you can have clip names with dots in them, and any width (except for ambisonics).
const cleanClipName = clipName && clipName.replace(/\.[LCRS](s|r|w|FE|ss|sr|tf|tm|tr|c)?$/, "");