Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run shell command when render is complete (After Effects)

is there a way to programmatically run a shell command after a render has completed in Adobe After effects?

like image 712
user1661677 Avatar asked Aug 05 '26 09:08

user1661677


1 Answers

Execute a command line from After Effects

You can execute a command line with the sysmte.callSystem(cmdLineToExecute) function. Go see the After Effects Scripting Guide page 180 section System callSystem() method.

Here is an exemple whith a echo command : (callSystemreturns the command line return's) :

var commandOutput = system.callSystem("cmd.exe /c echo hi ");
alert(commandOutput);

This will output

hi

What is after /c is the command to execute in the cmd.

A more complex exemple from the scripting guide which get the system time :

var timeStr = system.callSystem("cmd.exe /c \"time /t\"");
alert("Current time is " + timeStr);

This will output

Curent time is 11:28

Open a command line from After Effects

Now if you are looking to open a command line in another window, you have to set the cmdLineToExecute as if you were in a command line.

On windows, if you want to open a command line in another window, you have to do this :

start cmd.exe

So if you want to do it from After

system.callSystem("cmd.exe /c start cmd.exe ");

Open a command line when the render is done in After Effects

This is a mix with @fabiantheblind's answer.

// Create a comp with a solid
var comp = app.project.items.addComp('test', 100, 100, 1, 1, 12);
comp.layers.addSolid([0.5, 0.5, 0.5], 'solid', 100, 100, 1, 1);
// Add the comp to the render queue
var rq_item = app.project.renderQueue.items.add(comp);
rq_item.outputModule(1).file = File('~/Desktop/out.mov');
rq_item.render = true;
// Set a function which will be called every frame when the comp will be rendering
// A boolean to be sure that the function called at the end is called once
var called = false;
rq_item.onStatusChanged = function() {
  while (rq_item.status === RQItemStatus.RENDERING) {
    // Is rendering...
    $.writeln('Rendering');

  }

  // When the render is finished
  if (!called && rq_item.status === RQItemStatus.DONE) {
    called = true;
    system.callSystem("cmd.exe /c start cmd.exe ");
  }

};
// Launch the render
app.project.renderQueue.render();

// If something goes wrong
app.onError = function(err) {
  $.writeln('ERROR ' + err);
};
like image 79
oktomus Avatar answered Aug 07 '26 22:08

oktomus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!