English 中文(简体)
After Effects (Mac) Execute a Script from Terminal
原标题:

I m trying to figure out how to execute an After Effects script from the command line.

Official documentation says:

Example (for Windows):
afterfx -r c:script_pathexample_script.jsx

And nothing for Mac. However I m trying:

open -b com.adobe.AfterEffects --args -r /script_path/example_script.jsx

And nothing happens. The program get opened though, but it seems that the script is never called.

Anyone had figured out this?

最佳回答

I got it working with this:

open -b com.adobe.AfterEffects --args /Users/[user]/Desktop/[folder]/file.aep

seems all I had to do was get rid of the r flag.

Good luck!

问题回答

This is actually documented here

You should now be able to use DoScriptFile (instead of DoScript) with Applescript. Something like:

tell application "Adobe After Effects CS6"
  DoScriptFile path/to/file.jsx
end tell

you can also call a specific function using external parameters by mixing this method with the one mentioned by MentalFish

  • make an applescript [in this case called ASfile.scpt]:

    on run argv
        set SomeName to (POSIX file (item 1 of argv))
        tell application "Adobe After Effects CS6"
            DoScriptFile SomeName
            DoScript item 2 of argv
       end tell
    end run
    
  • from python and assuming you have a 64bit machine you can call:

    ae = subprocess.call( arch -x86_64 osascript /AppleScriptLocation/ASfile.scpt %s/SomeScript.jsx "SomeFunction( %s )"  %( ScriptsFolder, ParameterFromPython),shell=True)
    

Apparently AE on Mac does not support command line execution of scripts: http://www.aenhancers.com/viewtopic.php?f=8&t=1903

This works, create an AppleScript that tells AE to run the script via the DoScript command:

set test to (POSIX file ("/Users/username/Desktop/test.jsx"))
tell application "Adobe After Effects CSYourVersionNumber"
    DoScript test
end tell

... and run the script via the command line as such (to run it in 32-bit mode):

arch -i386 osascript test.applescript

If you want to pass in the parameter of what script to launch you can do it like this:

on run argv
    set test to (POSIX file (item 1 of argv))
    tell application "Adobe After Effects CSYourVersionNumber"
        DoScript test
    end tell 
end run

Run the script and pass in the path to the jsx file:

arch -i386 osascript test.applescript /Users/username/Desktop/test.jsx

you could place it in the startup folder (I use windows, the folder in win is Adobe After Effects CS4/Support Files/Scripts/Startup). Scripts in that folder are executed upon AfterEffects booting up.

Might be helpful?

I would like to throw in here, some answers where great though possibly outdated. This code:

on run argv
    tell application "Adobe After Effects CC 2018"
        DoScriptFile item 1 of argv
    end tell
end run

For the applescript file works, the POSIX code does not. Then running it in the terminal for Mojave works like this:

osascript AppleScriptAETest.scpt "/Users/.../Your/file/here.jsx"

This works best for me.





相关问题
What does it mean "to write a web service"?

I just asked a question about whether it was possible to write a web-page-checking code and run it from free web server, and one supporter answered and said that it was possible only if I run "a web ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Ivy, ant and start scripts

I have a project that uses ant to build and ivy for dependencies. I would like to generate the start scripts for my project, with the classpath, based on the dependencies configured in Ivy, ...

热门标签