Copy link to clipboard
Copied
For certain jobs I have specific render requirements, so I made a Script UI button that queues the selected comp and applies render settings and output modules…
var myItems = app.project.selection;
var comp, item, outputModule;
for (var i = 0; i < myItems.length; i ++){
if (! (myItems[i] instanceof CompItem)) continue;
comp = myItems[i];
item = app.project.renderQueue.items.add(comp);
outputModule = item.outputModule(1);
outputModule.applyTemplate("Apple ProRes 422 HQ 16 Bit");
item.applyTemplate("Best Settings - 16 Bit");
}
It works great. However, I want to add a custom render destination that renders into a folder, and the folder name needs to be the name of the AE project. I don't want to change my default render location, so I need to change the output in this script instead.
I'm on a Mac and the location I need is /Volumes/Renders/[name of project]/
Is this possible? And if so, how would I do modify my code to do that?
Try this:
var myItems = app.project.selection;
var comp, item, outputModule, myFile, myFolder;
// make sure project has been saved
if (app.project.file == null) alert("save your project first!");
else {
for (var i = 0; i < myItems.length; i++){
if (myItems[i] instanceof CompItem) {
comp = myItems[i];
item = app.project.renderQueue.items.add(comp);
outputModule = item.outputModule(1);
outputModule.applyTemplate("Apple ProRes 422 HQ 16 Bit");
item.applyTemp
...
Copy link to clipboard
Copied
Try this:
var myItems = app.project.selection;
var comp, item, outputModule, myFile, myFolder;
// make sure project has been saved
if (app.project.file == null) alert("save your project first!");
else {
for (var i = 0; i < myItems.length; i++){
if (myItems[i] instanceof CompItem) {
comp = myItems[i];
item = app.project.renderQueue.items.add(comp);
outputModule = item.outputModule(1);
outputModule.applyTemplate("Apple ProRes 422 HQ 16 Bit");
item.applyTemplate("Best Settings - 16 Bit");
// create folder object from path, including project name stripped of extension
myFolder = new Folder("/Volumes/Renders/" + app.project.file.name.substring(0, app.project.file.name.lastIndexOf(".")));
// check folder exists
if (!myFolder.exists) {
// create it if it doesn't
if (!myFolder.create()) {
// if create() returns false is couldn't be created for some reason so break out of the for loop and end
alert("unable to create folder");
break;
}
}
//folder should now exist so create a file object using the folder path + the existing output module filename, then set the output module file
if (myFolder.exists) {
myFile = new File(myFolder.fsName + "/"+outputModule.file.name);
outputModule.file = myFile;
}
}
}
}
Copy link to clipboard
Copied
That works great!! Thanks again Paul! And also I appreciate the thoughtful additions you made such as making sure the project has initially been saved, and checking if the folder exists.
Copy link to clipboard
Copied
No problem. Those things were for my benefit too. First error I got when testing it was 'null is not an object' because I was using an unsaved test project!
To add to your list of required reading, here's the Adobe Javascript Tools guide which contains things like file system access, script UI and other things specific to Extendscript across Adobe apps but not specfic to After Effects. This is what I dipped into for a quick refresher when writing the code.
https://www.adobe.com/content/dam/acom/en/devnet/scripting/estk/javascript_tools_guide.pdf
Copy link to clipboard
Copied
Thanks! That's really helpful.
Copy link to clipboard
Copied
Hello Mark,
I just realized I did not properly word my question. What I meant to say is that in my case I need the script to instead of creating a folder in "/Volumes/Renders/[name of project]/ "... Would be created right next to the projects folder location, adding "-DELIVERY" to folders name.
Here is a visual example...
Thank you for your help,
Copy link to clipboard
Copied
Hi,
Thank you for the inside.
Could there be a way to set the default to a folder that would be treated right next to the project (regardless of its location). With the "name of the project" and "-DELIVERY" ?
Thank you,