Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How can I copy the contents inside a text file to SourceText property of a text layer by scripting?

  • How can I copy the contents inside a text file to SourceText property of a text layer by scripting?

    Posted by Adirai Maji on December 23, 2019 at 12:32 pm

    I know the way to get the text file using evalFile. But it only read the file. What I want to achieve is to copy the file inside the text file and apply it to the SourceText property of a text layer. How can I achieve that?

    ==================================================================================================
    Thanks in Advance…

    – Adirai Maji

    Andrei Popa replied 6 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Andrei Popa

    December 26, 2019 at 2:18 pm

    I’m not sure what your level of scripting is, but you should be able to understand this and even use the function in your own cases.


    var myFile = File.openDialog("Please select a file");
    var myLayer = app.project.activeItem.selectedLayers[0];
    copyFileToLayer(myFile, myLayer);

    function copyFileToLayer(myFile, myLayer){
    if(myFile.open("r")){
    var myString = myFile.read();
    myLayer("ADBE Text Properties")("ADBE Text Document").setValue(myString);
    myFile.close();
    }else{
    alert(myFile.error);
    }
    }

    Andrei
    My Envato portfolio.

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