Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions External text file that updates text in the composition

  • External text file that updates text in the composition

    Posted by Kyle Jennings on April 25, 2016 at 8:57 pm

    Hi,

    I’m trying to create a text layer that will reference an external .txt file so that if I update the .txt file, the text within the animation will update. I’m wanting to do this to make it easier to update our mortgage rates. Is this possible? I’ve been trying to use expressions to do this but haven’t had any luck. My current expressions code is below. The text in my .txt file is var comp1 = [“30 YEAR”, “3.628%”];. I’m getting the not found error

    myPath = "file://C:/Users/kjennings/Desktop/30yr.txt";
    try{
    $.evalFile ("file://C:/Users/kjennings/Desktop/30yr.txt");
    eval("Comp 1");
    }catch (err){
    "not found"
    }

    Ross Klettke replied 10 years ago 2 Members · 1 Reply
  • 1 Reply
  • Ross Klettke

    April 25, 2016 at 10:09 pm

    Prior to trying this out here I’ve never used external files — so take this with a grain of salt, but here’s what I got to work:

    Inside a text file I called externalText.txt: var comp1 = [“30 YEAR”, “3.628%”];

    The expression on the text layer’s “source text”:

    try{
    $.evalFile (“C:\\Users\\rklet\\Documents\\TEMP\\externalText.txt”);
    comp1[0];
    }catch (err){
    “not found”
    }

    ——

    Some things that might be issues in your code:

    myPath = “file://C:/Users/kjennings/Desktop/30yr.txt”; //this line not necessary
    try{
    $.evalFile (“file://C:/Users/kjennings/Desktop/30yr.txt”); //I don’t believe the file:// is necessary and, at least on my Windows computer, the file path uses \ not /. Also, maybe try doubling up the slashes (see my example above — I think this acts as what’s known as an “escape character”)
    eval(“Comp 1”); //there’s no variable named “Comp 1” in your text file. use “comp1” instead
    }catch (err){
    “not found”
    }

    Hope that helps!

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