New to Scripting. First Script.

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Posts: 2
Joined: October 3rd, 2013, 10:13 am

Hey guys, just signed up to the board, but been reading for a bit. Really good stuff on here and smart people.

I'm an assistant editor for a large post company in NY and am definitely intrigued by the automation from After Effects. Knowing exactly how it can help different workflows is definitely a part of the journey. I just finished my first script. It's pretty basic and I'd say it's mostly hacked together from different scripts and tutorials.

One of the things we need to do is make an NTSC version of a 23.98 HD file for SD deliveries and one of the methods I like best is through After Effects. I wrote this one to automate the process. Any thoughts or ways I could do it better?
Apologize in advance for the poor script writing and general redundant code.

app.beginUndoGroup("Undo Convert");

var proj = app.project; //Reference to project
var myItems = proj.items; //Reference to items in project
var newLocation = Folder.selectDialog("Select a render output folder..."); //Dialog to select output destination
var RQ = proj.renderQueue; //reference to renderQueue

var selectedItems = proj.selection; //References selected items in project
var selectedFootage = new Array(); //Creates a new Array container for footage from selected items

storeSelectedFootage(); //Run function to store selected footage
makeCompAndRender(); // Run function to make comp, add footage to comp, resize, and render
RQ.render(); //Renders out footage

function storeSelectedFootage()
for (var i=0; i < selectedItems.length; i++) //For loop that stops when total selected items reached
if (selectedItems instanceof FootageItem) //Checks if selecteditems is a footage item
selectedFootage[selectedFootage.length] = selectedItems; //if it is a footage item, stores it in new selectedFootage array

function makeCompAndRender()
for (var i=0; i < selectedFootage.length; i++) // For loop that stops when total selected footage reached
newComp = myItems.addComp(, 720, 486, 0.91, selectedFootage.duration, 29.97); // Add new NTSC comp for item in array of selected footage
newComp.layers.add(selectedFootage); //Add selected footage to new comp
newComp.layers[1].property("Scale").setValue([45.5, 45.5]); //Set scale value for the layer

var myRQItem = RQ.items.add(newComp); //Add comp to render Queue
myRQItem.applyTemplate("Best Settings"); //apply render template
myRQItem.outputModules[1].applyTemplate("ProRes HQ"); //Apply output template
var myFile = new File(newLocation.toString() + "/" +; //Sets output to new location and name
myRQItem.outputModules[1].file = myFile; //sets actual file output to previous variable


Post Reply