I'm trying to run an Adobe AE extendscript from the command line. I use the "-r" argument and I can run scripts fine. However, is it possible to pass in an argument to the script?
Like, if i run this from the command line:
C:\>"C:\Program Files\\Adobe\\Adobe After Effects CC\\Support Files\\AfterFX" -r "C:\Workspaces\MyAEScripts\AutomateSetup.jsx" hello
is it possible to get that "hello" into my AutomateSetup.jsx script? I've been googling for a while and can't find a solution to this.
For people who come across this question, and don't want to write a file, you can pass in arguments by using the -s switch which runs the argument to the AfterEffects program as a script. For example, you can do the following (Windows cmd):
afterfx.exe -s "var myArg="I'm a string!"; $.evalFile("Your path to script here")"
You could then access myArg from the script you run in the evalFile command. With this you could just pass in a single string containing your command line arguments, or make and set individual variables for what you need. Also note that you do NOT need to escape the quotes you use in the script line, just type it in as if it were just a text file (but do surround the line in quotes).
I'm a novice with After Effects scripting, so please correct if this is wrong in some way.
My workaround is to write the arguments to a file in the current working directory or under the directory where the script is, and then read them in the script.
You can get the working directory in Mac OS X using system.callSystem('pwd')
.
Under Windows, you can get the directory of the script using system.callSystem('cmd.exe /c "echo %cd%"'')
.