Created
May 5, 2015 09:56
-
-
Save atvKumar/889d736b6656e4768710 to your computer and use it in GitHub Desktop.
After Effects Script to create folders and render Compositions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright: Kumaran | |
function getSelectedComps(){ | |
var allItems = app.project.items; | |
selectedComps = new Array(); | |
for (var i = allItems.length; i >= 1; i--) { | |
eachItem = allItems[i]; | |
if ((eachItem instanceof CompItem) && eachItem.selected) { | |
selectedComps[selectedComps.length] = eachItem; | |
//$.writeln(eachItem.name); | |
} | |
} | |
return selectedComps; | |
} | |
function ChangeRenderLocations(renderPath, outputTemplate){ | |
var newLocation = renderPath; | |
var QTtemplate = outputTemplate; | |
if (newLocation != null) { | |
//app.beginUndoGroup("Change Render Locations"); | |
if ((app.project != null) && (app.project.items.length >= 1)){ | |
// Main code goes here. | |
var selectedComps = getSelectedComps(); | |
//alert(selectedComps.length); | |
for (i=0; i < selectedComps.length; i++){ | |
//alert (selectedComps[i].name); | |
app.project.renderQueue.items.add(selectedComps[i]); | |
} | |
for (i = 1; i <= app.project.renderQueue.numItems; ++i) { | |
var curItem = app.project.renderQueue.item(i); | |
if (curItem.status == RQItemStatus.QUEUED) { | |
var curOM = curItem.outputModule(1); | |
curOM.applyTemplate(QTtemplate); | |
var oldLocation = curOM.file; | |
var compFolder = new Folder(newLocation.toString() + "/" + selectedComps[i-1].name.toString()); | |
compFolder.create(); | |
curOM.file = new File(compFolder.toString() + "/" + oldLocation.name); | |
} | |
} | |
} | |
//app.endUndoGroup(); | |
} | |
} | |
function getOutputTemplates(){ | |
// Create a dummy Comp | |
var dummyComp = app.project.items.addComp("dummyComp", 1920, 1080, 1, 1, 25); | |
// Add to Render Queue | |
app.project.renderQueue.items.add(dummyComp); | |
// Get the set of output module templates | |
var OM = app.project.renderQueue.item(1).outputModule(1).templates; | |
// Loop through to find dummyComp | |
for (i=1; i<=app.project.renderQueue.numItems; ++i){ | |
var curItem = app.project.renderQueue.item(i); | |
if(dummyComp == curItem.comp){ | |
// remove it | |
curItem.remove(); | |
dummyComp.remove(); | |
}; | |
}; | |
return OM; | |
} | |
function myTool(thisObj){ | |
function _buildUI(thisObj){ | |
// Main Panel or Window (depending on Script>Run / ScriptUI Window) | |
var win = (thisObj instanceof Panel) ? thisObj | |
: new Window("palette", "Render Location Changer", [340,174,706,380]); | |
// UI Code Goes Here | |
win.renderLocation = win.add('edittext', [14,20,296,42], ''); | |
win.renderLocation.justify = 'left'; | |
win.setRenderLocation = win.add('button', [302,19,344,45], 'RL'); | |
//win.setRenderLocation.onClick = function () {this.parent.close(1);} | |
win.setRenderLocation.onClick = function () { | |
var newLocation = Folder.selectDialog("Select a render output folder..."); | |
this.parent.renderLocation.text = newLocation.toString(); | |
} | |
win.addRenderQueue = win.add('button', [204,49,346,75], 'Add to Render Queue'); | |
win.addRenderQueue.onClick = function () { | |
var test = this.parent.outputTemplates.valueOf(); | |
ChangeRenderLocations(this.parent.renderLocation.text, test.selection); | |
//alert(test.selection); | |
} | |
win.outputTemplates = win.add('dropdownlist', [14,51,191,73], getOutputTemplates()); | |
return win | |
} | |
// Build the UI | |
var myUI = _buildUI (thisObj); | |
// Check if Window, then show it (required for Script>Run) | |
if ((myUI != null) && (myUI instanceof Window)){ | |
myUI.center(); | |
myUI.show(); | |
} | |
} | |
myTool(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment