# Automate After Effects assets rendering via script and external data

I am often rendering quite large sets of assets (lower thirds, titles, etc) from AFX and it's really annoying to eg create lower third and then duplicate it and change texts. Especially when I later need to change something globally and have to return to every single copy of that graphic.

Is there maybe a way to load data from external file (like XML or JSON) and then repeat render for each row / set in that file? So I could basically create lower third with text fields "name" and "company" and then specify multiple values for those fields in external file and then just have AFX render my composition with each set of values?

Either way you can use external file to drive expressions (in older versions too) using the eval javascript function. I explain it on my blog thus:

If you have a file that contains something like this:

var vals = {"rotation":8, "scaleX":150, "scaleY":200};


you can use this expression, e.g. in the scale property:

\$.evalFile("/path/to/test.js"); // or "c:\path\to\test.js"
[eval(vals).scaleX, eval(vals).scaleY]


the first line reads the file and treats it as source for the expression, so vals is defined as an object with rotation, scaleX and scaleY properties, which we access as the value for our scale property.

In your case you'd be wanting to use the expression for the Source Text property, so your data file might be something like

var vals = {"comp1": {line1:"Doctor MCDoctorface", line2:"Surgeon"},
"comp2": {line1:"Skinner McHackett", line2:"Butcher}…
}


So that's an array of arrays, where each comp has 2 values, line1 and line2. In your expression you'd loop through the array, until you found the member of the outer array whose name matched thisComp.name and then use the appropriate member for line 1 and 2.

To automate your rendering you can use the built-in command line renderer aerender (aka aerender.exe). With a bit of shell scripting you can automate the whole workflow.

And also one little trick: you can copy-paste key-frames. And you can copy-paste it as text! Just copy all your animation key-frames and paste to notepad.exe or other text editor! Pretty cool? You can write own script in any language to generate text with same structure and import many data in AE in such way.

Unfortunately, this works only with animation key-frames. But this one day saved too much time for me.