select a batch of clips, consolidate, rename and go to the next marker
Hi,
I'm looking to develop a script for the following session standard:

The main goal is: selecting the first clip on the track called AUDIO REF and then run script that do the following actions on a loop (until there's no more markers)
1. Activate group (if it's not already activated)
2. Press ";" to go one track bellow
3. Consolidate clips
4. Rename each clip based on track name, in addition to this check marker name (it'll be number) and replace it on the part of the title Fxxx (no idea how to do this) This is related with the episode number.
5. Selects AUDIO REF Track
6. Go to the next marker
7. Select next clip on track
8. Loop this action until there are no more markers.
I have found different parts of scripts in the forum (which is great BTW) and I have tried to do this little "Frankenstein" but I'm not completely successful.
First problem is that I don’t know how to get step 4 done
Secondly, I guess I have to insert this script on a loop until there are no more markers but I'm not so sure how to insert this. Beyond that, the script it's not showing any error.
//Before run the script select the first clip of AUDIO REF - ALSO need to match AUDIO REF name track and 'lang' group name
//Activate lang group if it is not already activated
/**
* @param {string} groupName
* @param {boolean} targetValue Set to true (active) or false (inactive)
*/
function setGroupActive(groupName, targetValue) {
let grp = sf.ui.proTools.mainWindow.groupListView.childrenByRole('AXRow').map(r => {
let btn = r.childrenByRole('AXCell').allItems[1].buttons.first;
return {
groupName: r.childrenByRole('AXCell').allItems[1].buttons.first.title.value.split(/-\s/)[1],
btn,
isActive: btn.title.invalidate().value.indexOf('Active ') === 0,
row: r,
};
}).filter(g => g.groupName === groupName)[0];
if (!grp) throw `Group with name "${groupName}" was not found`;
if (grp.isActive !== !!targetValue)
grp.btn.elementClick();
}
setGroupActive("lang", true);
//Go one track below
sf.keyboard.press({
keys: "semicolon",
});
//Consolidate Clips
sf.ui.proTools.clipConsolidate();
// Step 4 that I don’t have any clue how to do it
//Select AUDIO REF track
function scrollTrackToTop(trackName) {
sf.ui.proTools.appActivateMainWindow();
const targetTrack = sf.ui.proTools.trackGetByName({ name: trackName }).track
targetTrack.trackScrollToView();
targetTrack.titleButton.mouseClickElement({
isControl: true,
isShift: true,
});
}
scrollTrackToTop('AUDIO REF');
//Go to the next marker
sf.ui.proTools.memoryLocationsGotoDelta({
delta: 1,
});
//Select next clip
sf.keyboard.press({ keys: "ctrl+tab", });
Can anyone give me some light about this issue please?
- AAna del Sol Perez Zamora @Ana_del_Sol_Perez_Za
Hi! Just posting here a partial answer to my huge question.
This question was solved by @Chris_Shaw, thanks again!