Didn't really have any time to think about it, but I was wondering if anybody already made a script that does that...
In a middle of a project where I have to move things a LOT between sessions and I want to delete all the empty tracks while selecting what I need to move, so have less track to import.
Cheers
- Christian Scheuer @chrscheuer2018-09-08 06:24:45.080Z
Something like this could work. For this to work all tracks (that you want to operate on) need to be visible, and you need to manually select the first track before starting the script.
sf.ui.proTools.appActivateMainWindow(); var lastSelectedName; function selectNextTrack() { //Select next track sf.keyboard.press({ keys: 'semicolon' }); //Make sure we changed tracks (we're not on last track) var newName = sf.ui.proTools.selectedTrackNames[0]; if (newName === lastSelectedName) return false; lastSelectedName = newName; return true; } //Repeat for each track until someone breaks the loop while(true) { var mi = sf.ui.proTools.getMenuItem('Track', 'Delete'); if (mi.exists) { //If this menu item exists it means the track is empty mi.elementClick(); } if (!selectNextTrack()) break; //we're out of tracks, break the while loop }
Christian Scheuer @chrscheuer2018-09-08 07:52:20.186Z
Oops also forgot to say. This script doesn't select all empty tracks. It deletes them; that was easier to implement.
- DDavide Favargiotti @dieffe
I tried this one, very cool. Don't understand exactly the code, but is's interesting.
The issue I found is that this script, once it deletes a track, it starts over from the first track to check if the track is empty: e.g. after deleting the 21st track in the session, the selection goes back to track one and check again each and every track.Shouldn't it be better if the script kept in memory two tracks names, the current one and the previous one, so that once it check the new one with the current one, and deletes it because it's empty, we can recap the previous previous track name and start checking the tracks from that one?
- In reply todieffe⬆:Christian Scheuer @chrscheuer2018-09-08 06:28:51.359Z
@dieffe also looking forward to seeing some of your own scripts in a package soon :) I'm sure you have a good collection. Please let me know if there's anything holding you back from being able to share.
- DDavide Favargiotti @dieffe
Thank you Christian, I’ll have a look later when I get to my studio.
The only reason I didn’t share anything yet is because I have yet to upgrade to the latest beta :) busy week editing, didn’t want to risk breaking any workflow as I have to work on a lot of dialogue.
And I think I will need some time to comment my scripts... especially to make clear when the script is working and when it breaks completely :) My scripts are mostly reckless macro tailor made on my workflow and don’t have a lot of safety nets.
If I have some time this weekend I’ll upgrade to the new betaChristian Scheuer @chrscheuer2018-09-08 07:26:28.435Z
Yay sounds great. Thank you @dieffe for the update. Let's keep in touch about how to collaborate on scripts etc. I'd love to give you feedback/reviews on your scripts as a help to make them more safe etc. Maybe that could help speed up the process :)
- DDavide Favargiotti @dieffe
Definitely, thank you!
And BTW this triggers one question: is it possible to share a package only to a specific user?
Eg to you just for testing purposes or to my team members? Is his something you're planning to implement?
- In reply todieffe⬆:Chris Atkins @iamchrisatkins
Hey! This is cool, but it deletes the AUX tracks! It also takes quite a lot of time :-)
- VIn reply todieffe⬆:Vanessa Garde @Vanessa_Garde
Hi there,
Thanks for the script, Christian.
Would it be possible to do this:
- On Audio Tracks Only,
- that are part of a selection, not the entire session?
- In stead of delete, hide and make inactive?
I am working on some pretty track heavy sessions and have to go and find all empty audio tracks that don't contain anything, and then hide and make inactive manually. This would tremendly help!
Thanks!
Vanessa G.
Christian Scheuer @chrscheuer2019-10-18 11:31:09.257Z
Yes certainly :) This script should do that:
sf.ui.proTools.appActivateMainWindow(); function processTrack(trackName) { sf.ui.proTools.trackSelectByName({ names: [trackName], deselectOthers: true }); if (sf.ui.proTools.selectedTrackNames[0] !== trackName) throw 'Could not select track: ' + trackName; //Refresh menu sf.ui.proTools.selectedTrack.trackScrollToView(); sf.ui.proTools.selectedTrack.titleButton.mouseClickElement(); var trackIsEmpty = sf.ui.proTools.getMenuItem('Track', 'Delete').exists; var trackIsAudioTrack = sf.ui.proTools.selectedTrack.title.value.indexOf('Audio Track') >= 0; if (trackIsEmpty && trackIsAudioTrack) { sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({ isRightClick: true, menuPath: ['Hide and Make Inactive'], }); } } function main() { var trackNames = sf.ui.proTools.selectedTrackNames.slice(); trackNames.map(processTrack); } main();
- SSimon Franglen @Simon_Franglen
Hi Christian,
I'm trying to adapt these scripts to Instrument and Midi tracks. It seems like the variable 'Instrument Track' doesn't exist, or at least, I can't get it to work on a small session with mixed Audio, Instrument and Midi Tracks.
In a perfect world, I'd have a single script that selected both empty Instrument and Midi tracks, ready for deletion. In our mega-huge instrument templates (500+ tracks) it would be immensely useful when passing these on.Here's what I tried so far:
sf.ui.proTools.appActivateMainWindow(); function isTrackEmptyInstrumentTrack(trackName) { sf.ui.proTools.trackSelectByName({ names: [trackName], deselectOthers: true }); if (sf.ui.proTools.selectedTrackNames[0] !== trackName) throw 'Could not select track: ' + trackName; //Refresh menu sf.ui.proTools.selectedTrack.trackScrollToView(); sf.ui.proTools.selectedTrack.titleButton.mouseClickElement(); var trackIsEmpty = sf.ui.proTools.getMenuItem('Track', 'Delete').exists; var trackIsInstrumentTrack = sf.ui.proTools.selectedTrack.title.value.indexOf('Instrument Track') >= 0; return trackIsEmpty && trackIsInstrumentTrack; } function main() { var originalTrackNames = sf.ui.proTools.trackNames.slice(); var trackNamesToSelect = originalTrackNames.filter(isTrackEmptyInstrumentTrack); sf.ui.proTools.trackSelectByName({ names: trackNamesToSelect, deselectOthers: true, }); } main();
Christian Scheuer @chrscheuer2020-03-19 22:38:47.334Z
Hi Simon.
Try this - this version selects all empty MIDI and Instrument tracks (and is a lot faster than the original script):
sf.ui.proTools.appActivateMainWindow(); function isTrackEmptyInstrumentOrMIDITrack(trackName) { sf.ui.proTools.trackSelectByName({ names: [trackName], deselectOthers: true, }); if (sf.ui.proTools.selectedTrackNames[0] !== trackName) throw 'Could not select track: ' + trackName; //Refresh menu sf.keyboard.press({ keys: 'down' }); var trackIsEmpty = sf.ui.proTools.getMenuItem('Track', 'Delete').exists; var trackIsInstrumentTrack = sf.ui.proTools.selectedTrack.title.value.indexOf('Inst Track') >= 0; var trackIsMIDITrack = sf.ui.proTools.selectedTrack.title.value.indexOf('MIDI Track') >= 0; return trackIsEmpty && (trackIsInstrumentTrack || trackIsMIDITrack); } function ensureSettings() { //Ensure Link Track and Edit Selection is turned on if (sf.ui.proTools.mainWindow.cursorToolCluster.linkTrackAndEditSelectionButton.value.invalidate().value !== "Selected") sf.ui.proTools.mainWindow.cursorToolCluster.linkTrackAndEditSelectionButton.elementClick(); } function main() { ensureSettings(); var originalTrackNames = sf.ui.proTools.trackNames.slice(); var trackNamesToSelect = originalTrackNames.filter(isTrackEmptyInstrumentOrMIDITrack); sf.ui.proTools.trackSelectByName({ names: trackNamesToSelect, deselectOthers: true, }); } main();
- SSimon Franglen @Simon_Franglen
That's brilliant.
Just tested this with a session with 600 mixed empty/full audio/midi/instrument tracks. It took about 4 minutes to select all the empty midi/audioThis will save me days
ADDENDUM: It looks as though the graphics in Pro Tools are incorrectly. The actual tracks are selected correctly, but the show/hide seems to show errors.
Addendum 2: I spoke too soon. Later on in the scan there are errors, empty tracks are being selected as well as full ones.
Here's the session (no plugins needed) if you want to test it.
https://www.dropbox.com/s/wliggwkf0j6rmg9/Test%20empty%20full.ptx?dl=0- SSimon Franglen @Simon_Franglen
Also two other problems.
1: Can I define a selection of tracks
2: If I show only a selection of tracks, it doesn't stop with only the shown tracks, it then continues through all tracks in the sessionChristian Scheuer @chrscheuer2020-03-20 13:48:01.811Z
You can change this line:
var originalTrackNames = sf.ui.proTools.trackNames.slice();
to
var originalTrackNames = sf.ui.proTools.visibleTrackNames.slice();
for it to only work on the visible tracks - and I think you can use
selectedTrackNames
to start at the selected tracks.Christian Scheuer @chrscheuer2020-03-20 14:01:01.356Z
Try this - it has some improvements and only works on the visible tracks:
sf.ui.proTools.appActivateMainWindow(); function isTrackEmptyInstrumentOrMIDITrack(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName }).track; var trackIsInstrumentTrack = track.title.value.indexOf('Inst Track') >= 0; var trackIsMIDITrack = track.title.value.indexOf('MIDI Track') >= 0; if (!(trackIsInstrumentTrack || trackIsMIDITrack)) return false; track.trackSelect(); if (sf.ui.proTools.selectedTrackNames[0] !== trackName) throw 'Could not select track: ' + trackName; //Refresh menu sf.keyboard.press({ keys: 'comma, period' }); var trackIsEmpty = sf.ui.proTools.getMenuItem('Track', 'Delete').exists; return trackIsEmpty; } function ensureSettings() { //Ensure Link Track and Edit Selection is turned on if (sf.ui.proTools.mainWindow.cursorToolCluster.linkTrackAndEditSelectionButton.value.invalidate().value !== "Selected") sf.ui.proTools.mainWindow.cursorToolCluster.linkTrackAndEditSelectionButton.elementClick(); } function main() { ensureSettings(); var originalTrackNames = sf.ui.proTools.visibleTrackNames.slice(); var trackNamesToSelect = originalTrackNames.filter(isTrackEmptyInstrumentOrMIDITrack); sf.ui.proTools.trackSelectByName({ names: trackNamesToSelect, deselectOthers: true, }); sf.keyboard.press({ keys: 'comma, period' }); } main();
When it's done you may have to cmd+click one selected track to make sure the "Track -> Delete" menu is updated. If it has no "..." after Delete you know that it succeeded.
- SSimon Franglen @Simon_Franglen
That's working here. The delete seems to reflect the tracks correctly. awesome
- SIn reply todieffe⬆:Simon Franglen @Simon_Franglen
I tweaked it for audio tracks selection as well
sf.ui.proTools.appActivateMainWindow(); function isTrackEmptyAudioTrack(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName }).track; var trackIsAudioTrack = track.title.value.indexOf('Audio Track') >= 0; if (!(trackIsAudioTrack)) return false; track.trackSelect(); if (sf.ui.proTools.selectedTrackNames[0] !== trackName) throw 'Could not select track: ' + trackName; //Refresh menu sf.keyboard.press({ keys: 'comma, period' }); var trackIsEmpty = sf.ui.proTools.getMenuItem('Track', 'Delete').exists; return trackIsEmpty; } function ensureSettings() { //Ensure Link Track and Edit Selection is turned on if (sf.ui.proTools.mainWindow.cursorToolCluster.linkTrackAndEditSelectionButton.value.invalidate().value !== "Selected") sf.ui.proTools.mainWindow.cursorToolCluster.linkTrackAndEditSelectionButton.elementClick(); } function main() { ensureSettings(); var originalTrackNames = sf.ui.proTools.visibleTrackNames.slice(); var trackNamesToSelect = originalTrackNames.filter(isTrackEmptyAudioTrack); sf.ui.proTools.trackSelectByName({ names: trackNamesToSelect, deselectOthers: true, }); sf.keyboard.press({ keys: 'comma, period' }); } main();
- SIn reply todieffe⬆:Sean McDonald @Sean_McDonald5
Hello All,
Im getting a SF error:
"delete empty tracks failed
referenceerror reply not defined
(DELETE EMPTY TRACLS line 41)any idea what I might be doing incorrectly?
thanks for your time
Christian Scheuer @chrscheuer2024-08-28 07:24:21.400Z
Hi Sean,
That sounds like a copy/paste error. There's none of the code in this page that contains an identifier "reply" - but there's a reply button after each post, so you may have accidentally included that in your copy.
- SSean McDonald @Sean_McDonald5
Thank you.
We will, re-copy and re-paste
- SIn reply todieffe⬆:Sean McDonald @Sean_McDonald5
Hi Christian,
When I am attempting to take your advice, and re-copy and paste.
I’m currently seeing this when booting SF todayAny advice in what I might be doing wrong?
Christian Scheuer @chrscheuer2024-08-28 17:30:43.532Z
Hi Sean,
This indicates it's not loading properly. I would try to restart SoundFlow. If that doesn't help, please open a new thread via Help/Issue so as to not burden the contributors to this thread (the issue you're seeing is not related to the topic of this thread).