Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Looking for (probably a script) that can batch-name compositions

  • Looking for (probably a script) that can batch-name compositions

    Posted by Adam Lewen on April 10, 2018 at 3:14 pm

    Hello.
    I have a few dozens of comps.
    They are all in the same main comp
    Before rendering, I do a tedious job of renaming those come with the appropriate Time-Code (of the main comp) for the ease of online.
    Is there some kind of a script anyone know about?
    Comp1_00115
    Comp2_00237
    ETC………
    I hope I am clear, tips and thoughts are greatly appreciated!

    Adam Lewen replied 8 years, 1 month ago 3 Members · 9 Replies
  • 9 Replies
  • Walter Soyka

    April 10, 2018 at 4:01 pm

    If you’re using frame numbers, you can do this directly with a file name template.

    Add the comp to the render queue, then click the disclosure triangle next to “Output To.” Choose “Comp and Frame Range” for a good start, or “Custom” to build your own.

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Mark Whitney

    April 10, 2018 at 7:21 pm

    You mean something like this?

    https://aescripts.com/ae-global-renamer/

  • Adam Lewen

    April 11, 2018 at 8:33 am

    Thanks for the input!
    great thoughts, and Mark, this is a super powerful tool!
    I think my very specific situation has to be done manually though…
    My situation is for example:
    Main Time line is “Episode” is an hour long.
    in it a have ~50 Comps in different lengths (never overlapping and between 5-15 sec long
    I want these comps to have in their name, the TimeCode In of where they on the Main timline…
    so for example
    Comp1_00115
    Comp2_00337
    ETC…

  • Walter Soyka

    April 11, 2018 at 10:38 am

    I wrote a quick script that should help. Save this as a .JSX file and call it like any other script:

    // A quick script to rename all comp layers in a containing comp with their start frame
    // Written 2018-04-11 by Walter Soyka and published on CreativeCOW

    // the script works in the active comp only; if there is none, nothing happens.
    comp = app.project.activeItem;
    if (comp instanceof CompItem) {
    app.beginUndoGroup("Add frame number suffix to comp layers");

    // step through all layers in the comp
    // if the layer is a comp, strip any trailing underscore/digit combination,
    // then add its starting frame as _#####
    for (var i = 1; i <= comp.numLayers; i++) {
    if (comp.layer(i).source instanceof CompItem) {
    comp.layer(i).source.name = stripFrameSuffix(comp.layer(i).source.name);
    var compStartFrame = padInteger(timeToFrames(comp.layer(i).inPoint + comp.displayStartTime), 5);
    comp.layer(i).source.name += "_" + compStartFrame;
    }
    }
    app.endUndoGroup();
    }

    function stripFrameSuffix(compName) {
    frameSuffix = new RegExp("_[0-9]*$");
    var newCompName = compName.replace(frameSuffix, "");
    return newCompName;
    }

    function padInteger(number, digits) {
    numberString = number.toString();
    while (numberString.length < digits) numberString = "" + "0" + numberString;
    return numberString;
    }

    function timeToFrames(t) {
    return Math.floor(t / app.project.activeItem.frameDuration);
    }

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Adam Lewen

    April 11, 2018 at 4:29 pm

    OMG!
    Walter thank you so much for your time!
    The script does work, but unfortunately I then get the:
    “This project contains expression errors 1 of 28” message…
    and
    some issues with the TC naming,
    for example a comp on 1:19:50:14 is getting 119763

    I will dive in the precomps and check, but I assume it will work flawlessly with expressionless comps!

    Thank you so much!

  • Walter Soyka

    April 11, 2018 at 6:14 pm

    TC was frame numbers. I had assumed from your 5-digit format above that’s what you were using. We’ll change that to HHMMSSFF.

    As for the expression errors, easily fixable by having the script tell Ae to try a search and replace on broken expressions after renaming the comp.

    V2:
    // A quick script to rename all comp layers in a containing comp with their start frame
    // Written 2018-04-11 by Walter Soyka and published on CreativeCOW

    // the script works in the active comp only; if there is none, nothing happens.
    comp = app.project.activeItem;
    if (comp instanceof CompItem) {
    app.beginUndoGroup("Add timecode suffix to comp layers");

    // set time display to TIMECODE
    timeDisplay = app.project.timeDisplayType;
    app.project.timeDisplayType = TimeDisplayType.TIMECODE;

    // step through all layers in the comp
    // if the layer is a comp, strip any trailing underscore/digit combination,
    // then add its starting timecode as _HHMMSSFF
    for (var i = 1; i <= comp.numLayers; i++) {
    if (comp.layer(i).source instanceof CompItem) {
    originalName = comp.layer(i).source.name;
    comp.layer(i).source.name = stripFrameSuffix(comp.layer(i).source.name);
    var compStartTime = comp.layer(i).inPoint + comp.displayStartTime;
    compStartTime = timeToCurrentFormat(compStartTime, 1/comp.frameDuration, false);
    compStartTime = compStartTime.replace(/:/g, "");
    compStartTime = compStartTime.replace(/;/g, "");
    comp.layer(i).source.name += "_" + compStartTime;
    app.project.autoFixExpressions(originalName, comp.layer(i).source.name);
    }
    }

    app.project.timeDisplayType = timeDisplay;
    app.endUndoGroup();
    }

    function stripFrameSuffix(compName) {
    frameSuffix = new RegExp("_[0-9]*$");
    var newCompName = compName.replace(frameSuffix, "");
    return newCompName;
    }

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Adam Lewen

    April 12, 2018 at 6:55 am

    Dear Walter.
    It works like a charm!
    THANK YOU!X1000
    Since it’s open to the public here. can I share this very useful script with other who might be in the need?
    of course I will keep all the credits and commenting!

  • Walter Soyka

    April 12, 2018 at 9:55 am

    Absolutely, share it however you see fit!

    Let’s call this #devforacause. If this script is helpful to you, please consider making a small donation (like what you might have paid if the script hadn’t been free) to a charity of your choice, and please encourage the folks you share it with to do the same.

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Adam Lewen

    April 12, 2018 at 10:11 am

    I Will!
    Thanks again.

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