python 脚本中的 extendscript return 参数

extendscript return argument from python script

我正在编写一个 extendscript 代码(Adobe After Effects - 但它基本上只是 javascript),它需要在服务器上迭代数万个文件名。这在 extendscript 中非常慢,但我可以用 python 在几秒钟内完成我需要的东西,无论如何这是我的首选语言。所以我想 运行 一个 python 文件和 return 一个数组返回到 extendscript。我可以 运行 我的 python 文件并通过创建和执行批处理文件来传递参数(根文件夹),但是如何将结果(数组)传递回 extendscript?我想我可以写出一个 .csv 文件并读回,但这似乎有点 "hacky".

在 After Effects 中,您可以使用 "system" 对象的 callSystem() 方法。这使您可以访问系统的 shell,因此您可以 运行 代码中的任何脚本。因此,您可以编写 python 脚本来回显或打印数组,这实际上就是 system.callSystem() 方法返回的内容。这是一个同步调用,因此它必须在 ExtendScript 中的下一行执行之前完成。

实际代码可能是这样的:

var stdOut = system.callSystem("python my-python-script.py")