Strip Silence Script for big amount of tracks.
Hi all,
I found a Script really useful for me. Here comes:
// NOTE: Setup Strip Silence with your preferred settings before running this script
function stripTheSilence(trackHeader) {
//Select track
trackHeader.trackSelect();
//Scroll track into View
trackHeader.trackScrollToView();
// Select All Clips In Track
sf.keyboard.press({
keys: 'cmd+a'
});
// Click Strip Button
sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first.buttons.whoseTitle.is("Strip").first.mouseClickElement();
}
function main() {
// Set Pro Tools frontmost
sf.ui.proTools.appActivateMainWindow();
//Get selected tracks
const selectedTrackHeaders = sf.ui.proTools.selectedTracks.trackHeaders;
const origSelectedTracks = sf.ui.proTools.selectedTrackNames
// Declare stripSilenceWin Variable as Strip Silence Window
var stripSilenceWin = sf.ui.proTools.windows.whoseTitle.is("Strip Silence").first;
if (stripSilenceWin && stripSilenceWin.exists) {
//Strip Silence IS open, do nothing
} else {
//Strip Silence is NOT open
// Open Strip Silence
sf.ui.proTools.menuClick({
menuPath: ['Edit', 'Strip Silence']
});
// stripSilenceWin.getElement("AXTitleUIElement").elementWaitFor();
}
selectedTrackHeaders.forEach( trackHeader => {
stripTheSilence(trackHeader)
});
// Close Strip Silence
sf.ui.proTools.viewCloseFocusedFloatingWindow();
// Re-select original tracks
sf.ui.proTools.trackSelectByName({
names: origSelectedTracks
});
}
main();
However, I've detected and issue when there are some Aux Tracks (or different tracks than Audio Tracks) within the selected tracks. It seems like Strip Silence doesn't work on Aux Tracks.
My question is: Is there any way to skip the Aux Tracks or only apply the script on Audio Tracks when selected tracks contains different track types?
Besides, I've detected that if selected tracks are not all visible (I mean, all of selected tracks exceed the size of the screen) the script also crash. Y don't know if there is a way to make the script auto scroll down to be able to continue doing its stuff along all selected tracks.
Thanks so much in advance for your help guys!
- samuel henriques @samuel_henriques
Hello Alex,
To process only on audio tracks, replace:
const selectedTrackHeaders = sf.ui.proTools.selectedTracks.trackHeaders;
with:
const selectedTrackHeaders = sf.ui.proTools.selectedTracks.trackHeaders.filter(h => h.title.invalidate().value.endsWith("- Audio Track "));
About the scrolling, it should do it, and it's working on mine.
If you keep getting it, make a screen recording and I'll have a look.
Hope this helps.