Skip to main content
DrVenkman
Participant
March 27, 2023
Question

Powershell command to open After Effects project and run a script on opening

  • March 27, 2023
  • 3 replies
  • 1673 views

In the same directory, wanting to get a Powershell command to open a after effects file, and also run a script file that also exists in that directory.
I can get after effects to open, but cannot get it to also run a script once the project is open.
any ideas?

This topic has been closed for replies.

3 replies

Legend
March 27, 2023

You can use `Invoke-Command` as in Dataclay's cli launcher for  running AE + Templater tasks via command line:

 

$cmd = "$app_dir\afterfx.exe"
$cmd_args = "$ui_switch $m_switch -r  $PSScriptRoot\$templater_filename"

"
`t`tInvoking Adobe After Effects $v =>
`t`t`t$cmd $ui_switch $m_switch -r `"$PSScriptRoot\$templater_filename`"
"

$scriptblock = {

    param($cmd, $cmd_args)

    $process = New-Object system.Diagnostics.Process

    $si = New-Object System.Diagnostics.ProcessStartInfo
    $si.FileName = $cmd
    $si.Arguments = $cmd_args
    $si.UseShellExecute = $false
    $si.RedirectStandardOutput = $true

    $process.StartInfo = $si
    $process.Start() | Out-Null

    do {
        Write-Host `t`t`t $process.StandardOutput.ReadLine()
    } until ($process.HasExited)

}

Invoke-Command -ScriptBlock $scriptblock -ArgumentList $cmd, $cmd_args

 

DrVenkman
DrVenkmanAuthor
Participant
March 27, 2023

Thank you for all the feedback!

Mathias Moehl
Community Expert
Community Expert
March 27, 2023

For running scripts from the command line see here:

https://ae-scripting.docsforadobe.dev/introduction/overview.html#running-scripts-from-the-command-line-a-batch-file-or-an-applescript-script

 

For opening a project, you could add a app.open command at the beginning of your script.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Mylenium
Legend
March 27, 2023

You would have to construct a powershell script that combs through the files and creates a command string from that. Nothing to do with AE, basically. It's definitely possible, but I'm not versed enough in the Windows Scripting host stuff to provide a quick example. Maybe check the Microsoft site...

 

Mylenium