Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects › Run AE Script on Multiple Comps

  • Run AE Script on Multiple Comps

    Posted by Jacob Thorup on April 23, 2019 at 7:20 pm

    I’m new to the scripting world, but I’ve created a script and I would like to execute it on all the comps in a folder (180 comps) without having to manually opening each comp and executing the script.

    Not sure how to approach this. I’ve been looking in the After Effects Scripting guide, but am not sure where to start.

    Thanks

    Walter Soyka replied 7 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Walter Soyka

    April 24, 2019 at 3:31 pm

    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]

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy