No internet connection
  1. Home
  2. How to

Select tracks by

By samuel henriques @samuel_henriques
    2022-10-14 11:33:11.888Z

    This is a continuation of Select All Tracks #post-24 that was getting confusing and out of the original thread.

    So @Tristan_Hoogland , I made a function that should work for any of you needs,
    This is all you can do :

    Here you go:

    /**
    * @param {Object} param
    * @param {'Routing Folder Track'|'Basic Folder Track'|'Audio Track'|'Aux Track'|'VCA Track'|'MIDI Track'|'Inst Track'|'Video Track'|'All Tracks' } [param.trackType]
    * @param {Array.<string>} [param.selectOnlyWithStrings]
    * @param {Array.<string>} [param.excludeWithStrings]
    * @param {boolean} [param.excludeInactive]
    */
    function selectTracksBy({ trackType = "All Tracks", selectOnlyWithStrings = [], excludeWithStrings = [], excludeInactive = false }) {
    
        sf.ui.proTools.trackDeselectAll();
    
        let type = trackType === "All Tracks" ? "Track" : trackType
    
        let names = sf.ui.proTools.invalidate().visibleTrackHeaders.filter(track => {
    
            const muteBtn = track.buttons.whoseTitle.is("Mute").first
            const isInactive = muteBtn.exists ? muteBtn.value.invalidate().value === "inactive" ? false : true : true
    
    
            return (track.title.value.trim().endsWith(type)) &&
                (selectOnlyWithStrings.length >= 1 ? selectOnlyWithStrings.some(el => track.normalizedTrackName.indexOf(el) >= 0) : true) &&
                (excludeWithStrings.length >= 1 ? !excludeWithStrings.some(el => track.normalizedTrackName.indexOf(el) >= 0) : true) &&
                (excludeInactive ? isInactive : true)
        });
    
        if (names.length === 0) return;
    
        sf.ui.proTools.trackGetByName({ name: names[0].normalizedTrackName }).track.trackScrollToView();
        sf.ui.proTools.trackSelectByName({
            names: names.map(t => t.normalizedTrackName),
            deselectOthers: true,
        });
    };
    
    
    selectTracksBy({ trackType: "Audio Track", excludeWithStrings: ["TH MIX", "ROUGH MIX", "ANOTHER WORD"], excludeInactive: true });
    

    Linked from:

    1. Select All Tracks
    • 0 replies