Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Script won't run from command line execution

New Here ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

I've reviewed numerous solutions and none of them work. I need to execute a script in After Effects by launching through python.  I've found the generic solution:
"C:/Program Files/Adobe.../AfterFx.exe" -r "Path/to/my/script/myScript.js";
If I paste this into the windows command prompt, the first part opens/runs afterfx just fine, but it doesn't run the script.  If I run the script from within AFX (File:Scripts:Run Script File) it executes correctly. Every variation I've found of this generic solution doesn't work either.

Ultimately I need to run this from python:
this_aep = 'X:/path/targetAfterfxFile.aep'
os.system(this_aep )
cmd = '"C:/Program Files/Adobe.../AfterFx.exe" -r "Path/to/my/script/myScript.js";'
os.system(cmd)

Please help.  I'm not a java person or a windows programmer. How can i get AFX to run the damn script automatically?  It needs to run on a loaded aep file, so running it on startup won't work and I don't want to to run every time AFX opens.

TOPICS
Scripting

Views

106

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

What are the contents of the script?  When you run it outside of AE, does any line execute?  Are you logging anything from the script to an external file?

 

If the script works when running within AE, but then doesn't work running it from the command line, the script is probably doing something that requires AE to be running.

 

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

The script saves as a new file, replaces some footage, renames some text, and renders to a directory provided by a json generated by maya.  Everything inside the script executes like it's supposed to if i run from within AfterFX or ctrl+R from visual studio.  I need to be able to execute it through python as part of an automated process.  If I try to execute through the command line, if AE isn't open it will open it, but it does nothing else, like it's not reading the script at all. 

Yes, AE needs to be running and that's not the problem.  I have a python command that opens the correct file in After effects (it's just a system call to the file) and then I need to have AE execute the script with that file open.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

anyone?  please help.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

Running an AE script from the command line will open a separate copy of After Effects. It won't run the script in the copy of After Effects that is already open.

 

Rather, you need a script that opens the AE project and runs what you need to do all in one go.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

LATEST

Great.  How do i do that?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines