Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects AfterFX command line and script argument

  • AfterFX command line and script argument

    Posted by Tobias Kraze on March 27, 2008 at 3:54 pm

    Greetings,

    I’m currently trying to batch render a larger number of projects in AE CS3 (Windows XP), and the easiest thing for me would be to trigger rendering of a composition within an .aep from a batch script (.bat).

    Since the output needs to be in NTSC and PAL, I have used Jeff Almasol’s excellent rd_CompSetter.jsx script to set the frame rates of all comps to PAL (all layers are based on stills).

    Now, what I would like to do is write a batch script to start afterfx, open the project file (xyz.aep) which is the NTSC version, and then run the script (rd_CompSetter.jsx) to set the framerate to 25 before rendering the composition.

    However, apparently there is no way to simply use “Afterfx xyz.aep -s rd_CompSetter.jsx”, because it is not possible to have two arguments here, only either the .aep file or the script file.

    I thought that one way to work around that limitation is to use a script as an argument, something like

    afterfx -s “app.open(new File(‘xyz.aep’));

    There are two problems with this approach:

    1) The file doesn’t seem to open. After effects starts properly, the info line shows that it is loading the project, and once it has reached 100% AE simply shuts down without an error.

    2) I don’t know how to run a script from within a script. E.g. would ‘ afterfx -s “app.open(new File(‘xyz.aep’)); /rd_CompSetter.jsx” ‘ work?

    I cannot use aerender because I need to trigger the CompSetter script first, so that is not an option either.

    Many many thanks if you know of any possible solutions.

    Regards,
    Tobias

    Jason Ladew replied 12 years, 6 months ago 3 Members · 6 Replies
  • 6 Replies
  • Tobias Kraze

    April 4, 2008 at 12:19 pm

    I kind of found a solution / workaround for this problem. I’m just posting the solution here for anyone who has the same problem.

    One way to pass script arguments/variables on the command line is by creating a temporary file in the .bat file and have the after effects script read this file. This way you can set up the

    e.g. the test.bat would look like this:

    echo %1 > temp.txt
    afterfx.exe -r “\test.jsx”

    and the test.jsx file would start like this:

    var tempFile = new File(path to temp.txt file);
    tempFile.open();
    userVar = tempFile.read();

    This way you could even create a list of configuration parameters and then trigger the after effects script. To pass a variable/string to an after effects script this way you would just have to trigger the .bat file:
    test.bat myString

    I used it to pass the name of the project file that the jsx file should open, and therefore manage batch rendering with variable project file names AND a custom script.

    Regards,
    Tobias

  • Kirill Pavlov

    December 31, 2010 at 1:11 pm

    Greetings.

    The same problem – trying to find the way to make *.bat-file or shortcut to make AE open my project and then automatically run script.

    Havу you sucseed finding the way to solve this problem?

    Thank you.

    Director of animation and CG

  • Tobias Kraze

    January 3, 2011 at 10:04 am

    Hi there,

    Please see my previous post for a detailed explanation. I haven’t found any other solution other than this workaround, and to be honest I didn’t pursue it any further.

    Feel free to contact me if you are still having trouble with it. If you found some kind of solution to this problem then please post it as it might come in handy for other users. Thank you 🙂

  • Kirill Pavlov

    January 3, 2011 at 12:42 pm

    Thanks.

    Solved this problem by creating modified shortcut to AfterFX.exe.

    In shortcut prorperties add
    “C:\Program Files\Adobe\Adobe After Effects CS5\Support Files\AfterFX.exe” -r C:\“path“\“script name”.jsx

    to open your project add in the beggining of the script

    {
    var myPath = “/Project path/”;
    var myProjectName = “project name.aep”;
    var myProject = File(myPath + myProjectName);
    app.open(myProject);
    }

    and then paste script you want to run.

    Director of animation and CG

  • Tobias Kraze

    January 3, 2011 at 1:21 pm

    Interesting approach. Thanks for sharing it!

  • Jason Ladew

    November 8, 2013 at 5:06 pm

    Hello,
    I am doing a project where I want to change text on an AE Project and then render it to a video, strictly from the command line. Here’s my https://forums.adobe.com/thread/1330532. I found your solution which seems promising of calling from the batch file the script which in turn opens the aep project and does its job.

    1) Do you think this will work what I am looking at?
    2) Are there any other solutions you have found or made since 2011. You’d think later versions would increase capability.

    Thanks for any input.

    Jason

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy