Event Scripts

A script is a file consisting of commands written in a programming language to be executed by a computer. In the context of Templater, "event scripts" are scripts that are executed when Templater broadcasts an event. These scripts hook into Templater's processes allowing you to extend its automation capability. Templater supports two types of event scripts.

  • Shell Scripts — These scripts allow you to interact with assets such as files and perform tasks like moving or transferring files, sending notifications, updating databases, transcoding output files, and sending emails. You can write shell scripts in any language available in your system's environment. See Using Shell Scripts for more information.
  • ExtendScripts — These scripts allow you to interact with objects within the After Effects project file, such as project assets, compositions, layers, key frames, and effect parameters. You must write these scripts using the ExendScript scripting language and toolkit. See Using ExtendScripts for more information.

A Shell Script and an ExtendScript can be simultaneously registered to listen for a single event. In this case, the registered Shell Script will always execute before the registered ExtendScript.

Dataclay's code repository on GitHub contains sample shell scripts and ExtendScripts intended to be executed when Templater broadcasts specific events.

NOTE  Templater Bot must be installed and activated to make use of event scripts.

WARNING  Breaking Changes
As of Templater 2.7 the “For all commands, use job details as arguments” preference is deprecated. If your application makes use of the deprecated preference, your registered event scripts will fail. You must explicitly append arguments to shell scripts if they are necessary. Verify that you are explicitly passing arguments to your scripts, especially if you are using Templater’s command line interface. In the templater-options.json file, you can no longer use the “job_detail_args” property inside the “bot” object within the “prefs” object.

Frequently Asked Questions about Event Scripts

Why use Event Scripts of each type?
Shell scripts are useful when you want to seamlessly integrate Templater into your existing application. For example, in a production scenario, you can merge, transcode , or compress Templater's output—all of which can be accomplished calling a command line application like ffmpeg within a script. You can also automate publishing output to a specific destination like an FTP site, or your YouTube, Vimeo, or JWPlatform account. You could also script notifications for when a batch of renders completes—email, text message, etc. With ExtendScripts, you can manipulate objects within the project file, enabling you to extend Templater's functionality with features that you need and want. Ultimately, you gain a great deal of flexibility with Templater by having the ability to hook into its processes.

When should I use event scripts?
You should use shell scripts when you need to do something with Templater's output or have Templater's functions integrate with an existing automated workflow. You should use ExtendScripts when you want to extend Templater’s feature set to meet your business needs or workflow goals.

What information from Templater can my scripts make use of?
You can pass information from Templater and After Effects to event scripts. To pass information to shell scripts, you append arguments to the scripts. Use Templater’s ExtendScript API to pass information to ExtendScripts.

What languages can I write event scripts in?
You can write shell scripts in any language available in your system's environment. You must write ExtendScripts using the ExendScript scripting language and toolkit along with the Templater ExtendScript API.

Can I use event scripts with Templater Pro?
Event scripts are only supported in Templater Bot.

Do event scripts write to log files?
Shell scripts do not log to a file by default, but from within the script, you can write code to redirect the standard output (stdout) and standard error (stderr) to a log file. Use the $D.log() method in Templater’s ExtendScript API to log messages and errors to Templater’s log files including templater.log and templater.err.