7

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.

ygetarts
  • 923
  • 3
  • 14
  • 29
  • 4
    I took a look around. There is no standard solution for argument passing. Sorry. But you could let your script read another file that holds the arguments. – fabianmoronzirfas Feb 21 '14 at 06:30

2 Answers2

7

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.

Jeff Stern
  • 71
  • 1
  • 2
  • What if you need to pass in many arguments. This solution seems a bit cumbersome. – ariestav Mar 01 '15 at 16:06
  • 1
    It is very cumbersome, but it was the best that I could come up with without creating a temporary file. I used this for a script where the command line was generated, so it wasn't a big deal, but it would not be very useful if you are just running it from a command prompt manually. – Jeff Stern Mar 17 '15 at 23:07
3

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%"'').

maxx777
  • 1,320
  • 1
  • 20
  • 37
TwilightSun
  • 2,275
  • 2
  • 18
  • 27