Just looking for a simple "select all tracks" command that only selects audio tracks and not aux, master, instrument, etc...
Linked from:
- Christian Scheuer @chrscheuer2022-01-18 13:26:14.790Z
Something ilke this should work:
function isAudioTrack(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName }).track; return track.title.value.indexOf('Audio Track') >= 0; } function selectAllAudioTracks() { var names = sf.ui.proTools.trackNames.filter(isAudioTrack); if (names.length === 0) return; sf.ui.proTools.trackGetByName({ name: names[0] }).track.trackScrollToView(); sf.ui.proTools.trackSelectByName({ names: names, deselectOthers: true }); } selectAllAudioTracks();
Brett Ryan Stewart @Brett_Ryan_Stewart
Thank you! Unfortunately its throwing this error?
samuel henriques @samuel_henriques
Hello Brett,
Christian might be busy with the new SF update.Try this:
function isAudioTrack(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName.normalizedTrackName }).track; return track.title.value.indexOf('Audio Track') >= 0; } function selectAllAudioTracks() { var names = sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack); 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 }); } selectAllAudioTracks();
Brett Ryan Stewart @Brett_Ryan_Stewart
Oh hell yes, that did it. Thanks Samuel!!
- In reply tosamuel_henriques⬆:TTristan Hoogland @Tristan
I've been utilizing this script in one of my more elaborate scripts - would you happen to have any guidance on selecting all audio tracks, but deselecting/ignoring specific tracks (preferably with the use of wild cards)?
My edge case is I'm trying to select all visible audio tracks in my session to print stems, but ignore the last 3 audio tracks in the session. Currently I tag the following on at the end of your script and it works fine, but it re-scans the entire session, which seems a bit redundant - and also I'd just prefer to use wildcards as the track names usually contain specific, yet consistent labeling (i.e. TH MIX, ROUGH MIX)
sf.ui.proTools.trackSelectByName({ names: sf.ui.proTools.selectedTrackNames.slice(0, -3), deselectOthers: true, });
thanks!
samuel henriques @samuel_henriques
Hello Tristan,
Here's a variation of the same script but now you can choose tracks that are a type AND/OR include in the name some key words./** * @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.includeInName] */ function selectTracksByTypeAndIncludesInName({ trackType = "All Tracks", includeInName = [] }) { let type = trackType === "All Tracks" ? "Track" : trackType let names = sf.ui.proTools.invalidate().visibleTrackHeaders.filter(track => { return (track.title.value.trim().endsWith(type)) && (includeInName.length >= 1 ? includeInName.some(el => track.normalizedTrackName.indexOf(el) >= 0) : 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, }); }; selectTracksByTypeAndIncludesInName({ trackType: "All Tracks", includeInName: ["TH MIX", "ROUGH MIX", "ANOTHER WORD"] });
In this case it will select "All Tracks" where its name includes "TH MIX" OR "ROUGH MIX" OR "ANOTHER WORD".
Add here:["TH MIX", "ROUGH MIX", "ANOTHER WORD"]
add as many key words as you want.Let me know if this is it
- TTristan Hoogland @Tristan
Thanks for this @samuel_henriques unfortunately I'm not having any luck with it - doesn't seem to do anything actually! ha. Not entirely sure what that could be?
samuel henriques @samuel_henriques
ahhh.
Could you share the complete track names you are trying to select,
and what you wrote hereincludeInName: ["TH MIX", "ROUGH MIX"]
?
Just so I test it to see what I missed on the code.- In reply toTristan⬆:
samuel henriques @samuel_henriques
Just updated the script with better features and usage.
But couldn't find anything wrong with the previous one.- TTristan Hoogland @Tristan
Hi Sam! Ahh I think this is working as you intended (which is actually very useful within itself!). What I was hoping was the complete inverse of what you've created here - I want to select all tracks, but then exclude specific tracks. Does that make sense?
samuel henriques @samuel_henriques
Woops! That's right, that's what the code you were using does. Let me think of a cool and fast way to go about this. When selecting all tracks using the all group click, the way Matt Friedman shared, it opens all the folder tracks, is that ok for you?
- TTristan Hoogland @Tristan
ha - all good! I'm sure it's going to come in handy too.
That's fine by me! (Maybe even preferred). Plus I barely use folder tracks anyway.
samuel henriques @samuel_henriques
Could you confirm the tracks you want unselected are always next to each other and all visible on the same screen ?
Two track together wouldn't be a problem, but if you think there is a chance they could be 20, I could have to change my idea.- In reply toTristan⬆:
samuel henriques @samuel_henriques
Presuming the last question is true, here's something.
Easiest and safest than this would be to create a group excluding these tracks and the script would just click that group symbol./** * @param {string} name */ function selectAllTracksFromGroupSymbol(name = "<ALL>") { sf.ui.proTools.groupsEnsureGroupListIsVisible(); // Get all groups info const groupListState = sf.ui.proTools.mainWindow.groupListView.invalidate().childrenByRole('AXRow').map(r => ({ groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1], groupSymbol: r.childrenByRole('AXCell').allItems[0].buttons.first, groupState: r.childrenByRole('AXCell').allItems[0].buttons.first.value.invalidate().value.replace("Selected. , ", ""), groupIsSelected: r.childrenByRole('AXCell').allItems[0].buttons.first.value.invalidate().value.startsWith("Selected.") })); groupListState.filter(grp => grp.groupName === name)[0].groupSymbol.elementClick(); }; /** * @param {Array.<string>} unselectOptions */ function selectAllTracksANDunselectTracksWith(unselectOptions) { const unselectTracks = sf.ui.proTools.visibleTrackHeaders.filter(track => unselectOptions.some(el => track.normalizedTrackName.includes(el)) ); unselectTracks[0].trackSelect(); unselectTracks[0].trackScrollToView(); unselectTracks[0].popupButtons.first.mouseClickElement({ isShift: true, isControl: true }); //No parameter will use by default group <ALL> selectAllTracksFromGroupSymbol(); unselectTracks.forEach(tr => tr.popupButtons.first.mouseClickElement({ isCommand: true })); }; // Exclude from selection tracks that include these strings selectAllTracksANDunselectTracksWith(["ROUGH MIX", "TH MIX"]);
- TTristan Hoogland @Tristan
Hey sam! This is cool, soooo close. The only issue is that it's also selecting all auxiliaries. The earlier script which focuses on the audio tracks still works best. I was wondering if there was also a way to make sure it ignores inactive tracks? I might try my hand at it in the next few days, just been bogged down in other scripts - ha!
Thanks so much man. SO close.
samuel henriques @samuel_henriques
Continuation here:
Select tracks by
- In reply tosamuel_henriques⬆:
Andrew Piland @Andrew_Piland
Hi Samuel,
I'm trying to alter this script to do Instrument Tracks instead and not having any luck.
samuel henriques @samuel_henriques
Hello Andrew,
If you are trying to select tracks by type, use this
Select All Tracks #post-12Andrew Piland @Andrew_Piland
Ah thank you so much! That post was super helpful
- MIn reply toBrett_Ryan_Stewart⬆:Matt Friedman @Matt_Friedman
Just because the title of this is Select All Tracks, I came up with this simple one.
I tried working with the script above but it seemed to have trouble on really big sessions with lots and lots of tracks with the error:
Could not restore selection of the right track (Select All Tracks: Line 11)So this script just clicks next to the ALL group to select all tracks.
sf.ui.proTools.mainWindow.tables.whoseTitle.is("Group List").first.children.whoseRole.is("AXColumn").whoseTitle.is("State ").first.children.whoseRole.is("AXRow").whoseValue.is("").first.children.whoseRole.is("AXCell").first.buttons.first.elementClick();
Brett Ryan Stewart @Brett_Ryan_Stewart
Very nice ,thanks Matt!
- GIn reply toBrett_Ryan_Stewart⬆:Glen Schaele @Glen_Schaele
that's pretty cool!
How does it work when i ionly want to "select all basic routing folders? "
Cant find proper commands for that.Thank you! :)
samuel henriques @samuel_henriques
I'm out of the office and can't test now.
But on my version of the code, on line 3 where it say 'Audio Track' replace with 'Routing Folder Track'. 'Folder Track' should select all folders.
Tomorrow I should be able to test it out, if it's not working for you.- GGlen Schaele @Glen_Schaele
Hey buddy, thanks for the quick response!
Right, so ATM i have this:
preformatted text ```function isAudioTrack(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName.normalizedTrackName }).track; return track.title.value.indexOf('Routing Folder Track') >= 0; } function selectAllAudioTracks() { var names = sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack); 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 }); } selectAllAudioTracks(); not working yet. Would love to hear back from you when you can. Cheers!
samuel henriques @samuel_henriques
Hello Glen,
This should work,/** * @param{{trackType: 'Routing Folder Track'|'Basic Folder Track'|'Audio Track'|'Aux Track'|'VCA Track'|'MIDI Track'|'Inst Track'|'Video Track'}} trackType */ function selectTracksByType({ trackType }) { const names = sf.ui.proTools.visibleTrackHeaders.filter(track => { return track.title.value.trim().endsWith(trackType) }); 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, }); } selectTracksByType({ trackType: "Basic Folder Track" });
If you type F2 between the quotes you'll get a list of all the track types
Christian Scheuer @chrscheuer2022-10-12 11:09:34.953Z
Excellent code, Samuel!
samuel henriques @samuel_henriques
Thank you so much Christian, I'm just adding to your code :)
- GIn reply toBrett_Ryan_Stewart⬆:Glen Schaele @Glen_Schaele
This really helped! Thank you very much!
- In reply toBrett_Ryan_Stewart⬆:Brenden @nednednerb
Hi there,
I used the script by Samuel, (didn't try previous ones).
I duplicated the script and made 4 to select different types of tracks. I made 4 keyboard shortcuts.
I then duplicated that set, to make versions with "deselectOthers: false," in order to use another 4 shortcuts which would include more kinds of tracks. That way I could use two shortcuts to quickly select Audio and Aux for example. Or two shortcuts to select Audio OR Aux (which the above script did perfectly).How is the deselectOthers supposed to work? I think I saw no mention of this above, has this part been varied and tested by anyone?
Raphael Sepulveda @raphaelsepulveda2022-10-17 03:21:35.055Z
@nednednerb, please see my reply in your other post!