ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Automatically set "Output to" to correct folder

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vahur Kuusk
Automatically set "Output to" to correct folder
on Nov 18, 2019 at 10:03:33 pm

Hello,

Is it possible to automatically set the output folder based to the location of the input footage?

I have to do tons of preview mov's from exr's and I would like to eliminate the manual folder searching in output module. Instead I would like to press a button (using Kbar for example) and in render queue link it automatically to the input exr location on disk.
Can this be done?

Thanks.


Return to posts index

Vahur Kuusk
Re: Automatically set "Output to" to correct folder
on Nov 22, 2019 at 1:59:33 pm

Here's what I have now. It gets me to render queue with correct file name, however the folder is still messed up. When I press render AE says:
"The directory originally specified in the selected output module no longer exists."

Clearly I've missed something. Any help is appreciated.

var myComp = app.project.activeItem;
var myFootage = app.project.item(1);
var myFolder = myFootage.parentFolder.path;
var rq = app.project.renderQueue;
var render = rq.items.add(myComp);

render.outputModules[1].file = new File(myFolder + "/" + myComp.name + "[DRAFT].mp4");


Return to posts index

Dan Ebberts
Re: Automatically set "Output to" to correct folder
on Nov 22, 2019 at 5:38:38 pm

myFootage.parentFolder is going to give you the folder in AE's project bin where the footage is located (probably the Root Folder if the footage is item 1). To get to the file system folder, you need to use myFootage.mainSource.path.

Dan



Return to posts index


Vahur Kuusk
Re: Automatically set "Output to" to correct folder
on Nov 22, 2019 at 8:22:00 pm

Thank you, Dan.

For some reason, I still got an "directory does not exist" error when trying
myFootage.mainSource.path;

However I managed to solve it temporarily using file name substrings.

This is not ideal, because I can only use it on this project, but if there is a way to make it not dependent on substrings, I am all ears.

----

Also, why I had to set second item (2) for "myFootage" is beyond me, because in the project bin the footage is clearly first from top. But this is the only way I got the script to run. Weird.

var myComp = app.project.activeItem;
var myFootage = app.project.item(2);
var myFolder = myFootage.mainSource.file;
var myLoc = myFolder.path.substring(0,49);
var rq = app.project.renderQueue;
var render = rq.items.add(myComp);

render.outputModules[1].file = new File(myLoc + "/" + myComp.name + ".mp4");
app.project.renderQueue.render()


Return to posts index

Tomas Bumbulevičius
Re: Automatically set "Output to" to correct folder
on Nov 29, 2019 at 9:03:25 am

Hey Vahur - how you are executing this script? By adding it directly into the KBar, or by linking external script file to be executed?

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Vahur Kuusk
Re: Automatically set "Output to" to correct folder
on Nov 29, 2019 at 9:09:54 am

I am adding it directly into the Kbar as a scriptlet. I press the custom button and it start rendering.


Return to posts index


Tomas Bumbulevičius
Re: Automatically set "Output to" to correct folder
on Nov 29, 2019 at 9:23:06 am

When you get location of a file, use 'parent' to get a folder location without working with strings.

You might need to 'convert' result to .toString() in order to pass the folder path as a proper type, but this will eliminate a custom need of strings processing anyways.

myFolder.parent;

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Vahur Kuusk
Re: Automatically set "Output to" to correct folder
on Dec 1, 2019 at 5:06:34 pm

Thank you Tomas, that worked perfectly.
.toString() is what I missed.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]