In this quick setup guide we will cover how to setup a basic scripting environment for both Mac and Windows. It will streamline your workflow by allowing you to code in your favorite text editor, and run your scripts from the Terminal (OSX) or Command Prompt (WIN) directly in After Effects via a simple command.

Note: This setup is an alternative to using the Adobe ExtendScript Toolkit (ESTK - Adobe’s integrated development environment (IDE) for programming ExtendScript). It is a personal preference whether to use the provided toolkit or your custom editor.

Let's Jump right in

Open you editor of choice. Let’s add a quick alert snippet - we will use this to check if the script is running properly once launched. Feel free to customize you alert message.

alert("Script OK");

Save the script as alert.jsx - notice the extension… After Effects scripts must have this extension in order to be run in AE.


MAC Setup

After Effects on Mac does not currently have the capabilities to run scripts directly via Terminal. We can remedy this with a quick workaround, by invoking the osascript command. OSA stands for Open Scripting Architecture, and it allows us to control a multitude of applications via scripting. The core scripting language used is Applescript - Apple’s own scripting language that allows you to automate tasks on your Mac OS - but Javascript and Objective C can also be used.

Osascript

In Terminal, type in the following command (we are using the Javascript language for this one):

osascript -l JavaScript -e "ae = Application('Adobe After Effects 2021'); ae.activate(); ae.doscriptfile('path/to/alert.jsx');" 
Launch the script in AE from Terminal.

So -l Javascript specifies the language we are using (default is Applescript), and our one line script is added after the -e flag; that specifies a statement.

Our one line Javascript code simply creates a variable ae that references the After Effects Application (specify the one you want, if available on your system). Then we open the specified version of AE, or focus on it if already open, by using activate(). Finally we run our .jsx script file using the doscriptfile() method.

Note: Make sure you specify your version of AE in the script. If you are not sure, navigate to your Applications folder or wherever your AE version is installed and check the version name there.

Find out the version name of AE by navigating to the folder where it's installed.
Find out the version name of AE by navigating to the folder where it's installed.

For launching even faster, without having to paste the code and amend every time for different versions, we've wrapped the osascript command above in a shell script - that allows us to simply specify the AE version number, and the .jsx script to launch. Check it out here:

GitHub - gfxhacks/ae-script-launcher: Launch a .jsx script in After Effects from the Command line.
Launch a .jsx script in After Effects from the Command line. - GitHub - gfxhacks/ae-script-launcher: Launch a .jsx script in After Effects from the Command line.

Applescript

As an alternative, we can write an Applescript and launch that using osascript. Open the Script Editor app or search for it in Spotlight. Then paste the following code, and save:

on run argv
	tell application "Adobe After Effects CC 2021" --specify your version of AE here.
		DoScriptFile item 1 of argv
	end tell
end run

Understanding the Applescript code

In essence, we are telling (tell) our version of After Effects to run the script (DoScriptFile) that we are specifying. The path to the script is retrieved from the argument (argv) that is passed once we will execute the code (in the next step...).

Let's move on by opening the Terminal app, then type in

osascript

Hit Spacebar once. Now drag and drop your Applescript file into the Terminal window. Next, repeat the drag and drop action but with your alert.jsx file instead.
Your command should look like this:

osascript path/to/yourApplescript.scpt “path/to/alert.jsx"

Note: The quotes that surround the jsx file path ensure that the path is passed as an argument and can be referenced inside the Applescript code (in our case it is passed to the DoScriptFile function that launches the script) - if you dropped a script file path containing spaces in your Terminal window, those spaces will be automatically escaped with a backslash: space\ here. Since we added the quotes already, we don't need to escape the spaces. But if we do, Applescript will assume that the backslashes are part of the file path so won't find your script. Make sure to remove any added backslashes within your quoted filepath.

Now hit Enter. After Effects should launch and, if all is working, it should run our alert.jsx script - you should receive an alert popup with the message you specified.

Alert popup in AE shows script launched successfully
Alert popup in AE shows script launched successfully

That’s it!


WINDOWS Setup

On Windows, After Effects comes installed with an executable that can be used to run scripts via Command Prompt.

First locate the AE executable named AfterFX.exe. This should be found in C:\Program Files\Adobe\yourVersionOfAE\Support Files\ - replace yourVersionOfAE with your current version of After Effects e.g. “Adobe After Effects 2021”.

Open Command Prompt. Drag and drop the AfterFX.exe executable into the Command Prompt window then hit Spacebar and type -r, hit Spacebar again and repeat the drag and drop but this time with your alert.jsx file. Your command should look similar to this:

path/to/AfterFX.exe -r path/to/alert.jsx

Now hit Enter. After Effects should launch and, if all is working, it should run our alert.jsx script - you should receive an alert popup with the message you specified.

Alert popup in AE shows script launched successfully
Alert popup in AE shows script launched successfully

Done!


Quick tips

Previous Command

In both Mac Terminal and Windows Command Prompt - you can call your previous command by pressing the up arrow key. Then Enter.

Command History

The following commands allow you to retrieve a list of previously executed commands:
MAC - in Terminal, type history and press Enter.
WIN - in Command Prompt press F7. Alternatively, type doskey /history and press Enter.


Welcome to the After Effects Scripting Guide! — After Effects Scripting Guide 0.0.1 documentation
After Effects Scripting Reference.
After Effects on Adobe Support Community
Find answers to your questions, or share your expertise with After Effects users in our vibrant community. Search discussions or ask a question about Adobe After Effects.
After Effects Scripting Forum & Community.
Introduction to AppleScript Overview
Introduces the technology for writing scripts to control applications. Useful for scripters and application developers.
Mac Automation and Apple Script docs.

Editors

Adobe apps available for download
Learn what Adobe apps are available to download and install. Adobe provides installers for current apps and the previous major version of each.
Adobe Extend Script Toolkit (Direct Download), then search for Extendscript Toolkit CC.
A hackable text editor for the 21st Century
At GitHub, we’re building the text editor we’ve always wanted: hackable to the core, but approachable on the first day without ever touching a config file. We can’t wait to see what you build with it.
Atom Editor.