No internet connection
  1. Home
  2. How to

First selected clip name to track name

By samuel henriques @samuel_henriques
    2024-03-13 13:28:23.171Z2024-03-13 17:15:38.614Z

    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();
    
    • 4 replies
    1. M
      Matt Friedman @Matt_Friedman
        2024-03-13 14:13:32.925Z

        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????

        1. T
          Tom Davis @Tom_Davis
            2024-03-13 16:43:30.294Z

            WOW! Thank you Samuel and Matt! Can't wait to try this out!

            Appreciate you both!

            td

            1. M
              Matt Friedman @Matt_Friedman
                2024-03-14 05:19:32.502Z

                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(".")
                
                1. M
                  Matt Friedman @Matt_Friedman
                    2024-03-25 17:39:41.010Z2024-03-25 21:27:08.092Z

                    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)?$/, "");