【问题标题】:After Effects (Mac) Execute a Script from TerminalAfter Effects (Mac) 从终端执行脚本
【发布时间】:2011-08-17 02:06:22
【问题描述】:

我正在尝试弄清楚如何从命令行执行 After Effects 脚本。

官方文档说:

Example (for Windows):
afterfx -r c:\script_path\example_script.jsx

Mac 没有。但是我正在尝试:

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

然后什么也没有发生。虽然程序打开了,但似乎从未调用过脚本。

有人发现了吗?

【问题讨论】:

    标签: macos scripting adobe terminal after-effects


    【解决方案1】:

    这实际上是记录在here

    您现在应该能够将 DoScriptFile(而不是 DoScript)与 Applescript 一起使用。比如:

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

    您还可以通过将此方法与 MentalFish 提到的方法混合使用外部参数来调用特定函数

    • 制作一个applescript [在本例中称为 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
      
    • 来自 python 并假设您有一台可以调用的 64 位机器:

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

    【讨论】:

    • 我不敢相信这不是 Adob​​e 记录的。你刚刚救了我!
    【解决方案2】:

    Mac 上的 AE 显然不支持命令行执行脚本:http://www.aenhancers.com/viewtopic.php?f=8&t=1903

    这可行,创建一个 AppleScript,告诉 AE 通过 DoScript 命令运行脚本:

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

    ... 并通过命令行运行脚本(以 32 位模式运行):

    arch -i386 osascript test.applescript
    

    如果你想传入要启动的脚本的参数,你可以这样做:

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

    运行脚本并传入jsx文件的路径:

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

    【讨论】:

    • 感谢分享。不过,Orangechicken 是对的,命令是 DoScriptFile 而不是 DoScript
    【解决方案3】:

    你可以把它放在启动文件夹中(我用的是windows,win里面的文件夹是Adobe After Effects CS4/Support Files/Scripts/Startup)。该文件夹中的脚本在 AfterEffects 启动时执行。

    可能有用吗?

    【讨论】:

      【解决方案4】:

      我想在这里抛出一些很棒的答案,尽管可能已经过时了。 这段代码:

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

      对于 applescript 文件有效,POSIX 代码无效。 然后在 Mojave 的终端中运行它,如下所示:

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

      这对我来说效果最好。

      【讨论】:

      • 我在运行脚本时遇到问题:osascript run.scpt "/Users/admin/test/test.jsx" run.scpt:84:88: script error: Expected end of line but found class name . (-2741)
      • 奇怪,是AE错误还是Applescript错误?
      【解决方案5】:

      我得到了它的工作:

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

      似乎我所要做的就是摆脱'r'标志。

      祝你好运!

      【讨论】:

      • 这只会打开一个 AEP 文件。它不运行脚本。 (至少在 CS6 中)您使用 AppleScript。 MentalFish 的答案在 CS4 中可能是正确的。但是在 CS6 中,如果您想从文件运行脚本,您可以使用 DoScriptFile(尽管 DoScriptFile 不在 CS6 脚本参考中……感谢 Adob​​e)。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-07-10
      • 2022-12-03
      • 2017-01-06
      • 2020-05-14
      相关资源
      最近更新 更多