简体   繁体   English

Adobe After Effects扩展脚本 - 如何从命令行运行脚本并传入参数?

[英]Adobe After Effects extend script - how to run script from command line and pass in arguments?

I'm trying to run an Adobe AE extendscript from the command line. 我正在尝试从命令行运行Adobe AE extendcript。 I use the "-r" argument and I can run scripts fine. 我使用“-r”参数,我可以运行脚本。 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? 是否可以在我的AutomateSetup.jsx脚本中获得“hello”? 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. 对于遇到此问题并且不想编写文件的人,可以使用-s开关传递参数,该开关将AfterEffects程序的参数作为脚本运行。 For example, you can do the following (Windows cmd): 例如,您可以执行以下操作(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. 然后,您可以从evalFile命令中运行的脚本访问myArg。 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. 我是After Effects脚本的新手,所以如果这在某种程度上是错误的,请更正。

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') . 您可以使用system.callSystem('pwd')在Mac OS X中获取工作目录。

Under Windows, you can get the directory of the script using system.callSystem('cmd.exe /c "echo %cd%"'') . 在Windows下,您可以使用system.callSystem('cmd.exe /c "echo %cd%"'')获取脚本的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM