Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions After Effects Expression – Pro Trick – Multiple Layer Names on 1 Text Layer

  • After Effects Expression – Pro Trick – Multiple Layer Names on 1 Text Layer

    Posted by Roland R. kahlenberg on June 10, 2025 at 7:23 am

    You’ll occasionally have to overlay a layer’s name in your After Effects comp. If you didn’t know better, you’d have 1 Text Layer for each Layer.

    BUTT there’s a better way …

    Apply this to the Source Text Property of a Text Layer –

    // Start of Expression

    let layerNames = “”;

    for (let i = 1; i <= thisComp.numLayers; i++) {

    if (i === index) continue;

    let targetLayer = thisComp.layer(i);

    if (http://targetLayer.active) {

    layerNames += Layer Index:${targetLayer.index} - ${http://targetLayer.name}\r\n;

    }

    }

    layerNames.trim();

    // End of Expression

    If you don’t have overlapping layers, then use the version of the Expression displayed at the end of this video –
    https://youtu.be/JXmoVWsuwUA

    Roland R. kahlenberg replied 1 week, 5 days ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    June 10, 2025 at 7:17 pm

    Roland,

    I’m guessing that some unintentional reformatting occurred when you posted your code. I’m taking a shot at what I think you might have intended here:

    let layerNames = "";
    for (let i = 1; i <= thisComp.numLayers; i++) {
    if (i === index) continue;
    let targetLayer = thisComp.layer(i);
    if (targetLayer.active) {
    layerNames += targetLayer.index + " - " + targetLayer.name + "\r\n";
    }
    }
    layerNames.trim();
  • Dan Ebberts

    June 11, 2025 at 3:24 pm

    Ah, I missed the template literal. So once you change the curly quotes to straight quotes and get rid of the http:// stuff, this should work:

    let layerNames = "";
    for (let i = 1; i <= thisComp.numLayers; i++) {
    if (i === index) continue;
    let targetLayer = thisComp.layer(i);
    if (targetLayer.active) {
    layerNames += 'Layer Index:${targetLayer.index} - ${targetLayer.name}\r';
    }
    }
    layerNames.trim();
  • Roland R. kahlenberg

    June 11, 2025 at 4:10 pm

    Thanks Dan. I just noticed the strange character insertions and yes, The “http://” insertion was WILD! LOL

    Thanks for tidying it up. 👌

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