Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script to copy comp name to comments?

  • Script to copy comp name to comments?

    Posted by Paul Roper on June 29, 2016 at 5:54 pm

    Hello,
    I have a lot (100+) of comps all named to describe what they do. I’d like this descriptive name to be copied into the comp’s comments, so it survives a comp-rename. I’ve poked around a few scripts and found that the comments field is readable by a script, so I assume it is also writeable. But I’m not sure how to proceed, so any help would be greatly appreciated!

    ~ Paul

    Paul Roper replied 9 years, 10 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    June 29, 2016 at 6:50 pm

    This should do it:


    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i) instanceof CompItem){
    app.project.item(i).comment = app.project.item(i).name;
    }
    }

    Dan

  • Paul Roper

    June 29, 2016 at 7:01 pm

    Thanks Dan!

    One more thing – this script processes ALL my comps. How can I limit it to the SELECTED comps? (I’m guessing it’d be a change to the app.project.numItems bit).

    motion graphics | VFX | web design | etc.
    https://paulroper.com/

  • Paul Roper

    June 29, 2016 at 7:13 pm

    I tried plucking bits from a previous script you’d created:
    var mySelectedItems = [];
    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i).selected)
    mySelectedItems[mySelectedItems.length] = app.project.item(i);
    }
    for (var i = 0; i < mySelectedItems.length; i++){
    var mySelection = mySelectedItems[i];
    var myComp = app.project.items.addComp(mySelection.name, 1920, 1080, 1, mySelection.duration, 24);
    var myLayer = myComp.layers.add(mySelection);
    var myTransform = myLayer.Effects.addProperty("Transform");
    myTransform.property(4).setValue(150);
    }

    and mashing it together with that one, without success. Scripting is indeed a very mysterious art, which makes expression-writing seem like a doddle in comparison!

    motion graphics | VFX | web design | etc.
    https://paulroper.com/

  • Dan Ebberts

    June 29, 2016 at 7:14 pm

    This should work:


    var items = app.project.selection;
    for (var i = 0; i < items.length; i++){
    if (items[i] instanceof CompItem){
    items[i].comment = items[i].name;
    }
    }

    Dan

  • Paul Roper

    June 29, 2016 at 7:18 pm

    PERFECT!

    Thank you!!!!

    motion graphics | VFX | web design | etc.
    https://paulroper.com/

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