Here’s some commented sample code that processes each comp selected in the project panel:
// put your comp-processing code in this function
// we're just going to add "_processed" as a suffix to the comp's name as proof of concept
function processComp(myComp) {
if (myComp instanceof CompItem) {
myComp.name += "_processed";
}
}
// this could be a massive change, so let's make sure we can undo it if we want
app.beginUndoGroup("Process selected comps");
// get the project selection so that we can change the items
// working directly on app.project.selection might cause the sort/selection order to change,
// so we'll work from an object that represents the initial state of the selection
var projectSelection = app.project.selection;
// step through the entire selection set. For each item that's a comp, call our processComp() function
for (var selectionIndex = 0; selectionIndex < projectSelection.length; selectionIndex++) {
if (projectSelection[selectionIndex] instanceof CompItem) processComp(projectSelection[selectionIndex]);
}
// close the Undo group after we've finished
app.endUndoGroup();
This should give you a good start. Let me know if you have any questions!
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn]