Hi. Here's a smattering of little scripts that I've found helpful when using After Effects. They're written in TypeScript and then compiled into JavaScript that After Effects understands.
I've been using these scripts for a long time, but there are always gonna be bugs. Always – always – back up your work (always).
Everything you need is in the zip file. Skip to the next bit.
OR if you're a glutton for detail, read on.
- Most of these use the wonderful aequery library. I've included it in the
lib
folder (I hope that's OK, kind and benevolent aequery authors). Follow the link if you want to learn more, or grab the latest version, but I get the feeling it's not updated much these days. - One of them uses
json2.js
, but in the source code it says "USE YOUR OWN COPY" literally, in all caps like that. So I guess that one is cool. - And
underscore.js
is in thelib
folder too, mainly to make up for the fact that After Effects still uses some ancient version of JavaScript that is missing a bunch of Array methods. But I digress.
- Download the zip file, unzip it. You'll get a folder with some
*.js
files (they're the ones you run in After Effects), and a folder namedlib
. Thelib
folder contains libraries you'll need to run the scripts. - Launch After Effects, and choose
File > Scripts > Run Script File …
. Navigate to the folder you just unzipped, choose the one that will bring you happiness, and kablammo you're in business. - Not working? Let me know.
Get your mitts on something like node and npm (or pnpm), head to the terminal, cd to the folder, and try this:
npm install
npm run build
- I'd like to use these scripts with KBar or something. How that be done?
- Uh sure that's possible I think. You'll need to rename the script's extension to
jsx
rather thanjs
though. My version of KBar only recognises*.jsx
files when adding a script.
- Uh sure that's possible I think. You'll need to rename the script's extension to
- Something isn't clear or doesn't work. Question?
- OK wow your question is interestingly phrased. But that's fine. Give me a shout and I'll try to help.
- allCompsToSameTime
- applyPresetAtBeginningOfSelectedLayers
- collectSelectionIntoFolder
- distributeLayerInPoints
- easeAlternateKeyframes
- easeLayerDurations
- embiggenSelectedComps
- evenlySpacedLayerMarkers
- fuzzyOpen
- highlightLatestComps
- highlightNestedComps
- hyphenate
- layerStartTimesToInPoints
- listComps
- listLayers
- nullsFromSelected
- lastSelectedIsParent
- parentUnderTopmost
- quickCompPrefixer
- quickLayerRenamer
- rectangleAroundComp
- selectAllPathProps
- selectAllColourProperties
- selectStrokesWithoutExpression
- selectDescendants
- selectEllipses
- selectIdenticalProperties
- selectImmediateChildren
- selectKeysToTheRight
- selectLayersWithoutParents
- selectNonNestedComps
- selectPropertiesByRegexp
- selectRelated
- selectStrokeColours
- selectStrokeWidths
- selectStrokesAndFills
- selectTopLevelGroups
- setupMaskAnimation
Sets the current time in all selected comps to 4 seconds. I wrote this to see titles after they've built, and ensure everything looks OK.
Also works with folders, just select top level folders and it will look in them (and their subfolders) for comps – thanks aequery!
(Wondering what "Poster Time" is? It refers to the thumbnail that's shown in the Project panel. Often my comps start out black, so I set the Poster Time to 4 seconds so I can see what's in the comp without opening it.)
If you apply a preset that contains keyframes, it will apply them at the current time. If you want to apply to several layers that have different in points, you have to do it manually. This will quickly apply a preset at the beginning of each selected layer.
Select the layers you want to apply the preset to, run the script, and choose the preset using the file dialog.
Select some items in the project panel (comps, folders, etc) and this script will collect them into a new folder with a witty and clever name of your choosing.
There are many scripts out there that do this … but this is mine. It distributes selected layers, by frame, starting where you have the time indicator.
Eases alternate keyframes on selected properties. Part experiment, part work-in-progress.
Select a group of layers and this will adjust the in and out points so that their overall duration eases out exponentially. Play with the constants at the top of the file to get different results.
Quick and rough way to embiggen a few comps
Evenly Spaced Layer Markers
Reads a plain text file that contains a comp ID, and opens that comp.
I use a numbering system for my comps, so I can keep track of versions. Each unique top-level comp starts with a two digit number, and if I need to bump the version then I append the version. For example if I had 74 versions of the 01-cool-intro comp:
01-cool-intro-01
01-cool-intro-02
...
01-cool-intro-74
… this script would select 01-cool-intro-74
.
This script descends into all folders and subfolders, and selects the highest version of each comp.
It uses the underscore.js library, which is included in the repo.
Note that this ONLY looks at the first two digits of the comp name, so if two separate comps begin with the same numbered prefix, it's not gonna work.
Select every comp that's nested in another comp.
Replace spaces in selected project items with hyphens.
A layer's inPoint is often the same as its startPoint. But if you've trimmed it (either a nested comp or a footage file, say) then the inPoint reflects the trimmed point, whereas the startPoint will reflect the "untrimmed" beginning of the layer.
This script will move the selected layers so that each one's startPoint lines up with their current inPoint is (moving the inPoint in the process).
BONUS THING: hold down alt (option on Mac) to line up all the layers' startTimes to the comp's current time.
Dumps a list of all the comps in the project to a JSON file for use with "fuzzyFinder".
Dumps a list of layers in the current comp to a plain text file.
Creates nulls at the same position as the selected layers, and parents them to each. Also moves each null to be directly above the layer it's parented to, and inherits its label.
Parents the selected layers to the last selected layer, while trying to keep the hierarchy intact.
Parents the selected layers to the topmost layer, while trying to keep any existing hierarchy intact.
Adds a prefix to the name of each selected comp. That's it.
Here's my favourite way to use this. If you prefix a comp with a name followed by a forward slash, during rendering it will be placed in a folder with that name. For example, if you have a series of comps named like so:
cool-comps/banana
cool-comps/mango
cool-comps/pear
… then the renderer will output files called "banana", "mango", and "pear" in a folder named "cool-comps" (if it exists).
I made a video about this nifty feature.
Asks for a prefix, and renames each layer to that prefix, with a number. e.g. with the prefix "foo", the layers would be named "foo:1", "foo:2", etc.
Make a shape layer with a rect the size of THIS comp. Holding down the alt key will add an expression to the size, so that it always matches the comp size. Default is blue, but the auto-sizing version is yellow. For some reason.
Selects every "path" property on selected layers.
Selects all the "colour" properties in the selected layers.
Selects all strokes without an expression. Not sure what the original goal
was, but I like the use of aeq()
, so here it stays.
Recursively select children of selected layers. You can right-click on a layer and do the same thing, but this is helpful enough that I wanted to assign a keyboard shortcut to it.
Selects all the layers with an ellipse in 'em.
Selects the same property on all layers, respecting the hierarchy. For example, if you've selected a property that looks like this:
property("Contents").property("Rectangle 2").property("Contents").property("Stroke 1").property("Stroke Width")
… the script will select the same property on other layers, but only if it matches the hierarchy exactly. Handy when you've duplicated a shape layer and want update the same property on all the instances.
Given a selection, select only the immediate children of those layers (not the whole tree).
With each selected property, select keys to the right of the current time. Deselect keys to the left.
Select layers in the active compostion that don't have any parent, while deselecting those that do.
Select all comps that are not nested in any other comp.
Select all properties that match a regex. Ignores properties that are usually hidden, like "Layer Styles" and "Material Options".
Uses aequery's Layer.relatedLayers() to select all parents and children of the selected layers.
Selects all "stroke colour" properties in the active composition.
Selects all the "Stroke Width" properties on selected layers.
Selects all strokes and fills on selected layers using the extremely nifty aeq function. It'll descend into groups and select strokes 'n' fills at any level.
Default is to select both strokes and fills. If you hold alt (option on Mac), it'll select only strokes. If you hold shift, it'll select only fills.
Operates on selected layers in current comp. Simplify shape layers by selecting all the top-level groups … which then you can group. If there are no top-level groups on a layer, it will deselect it and continue looking.
NOTE: this seems to run faster if you select all the layers? Rather than just one. Weird
This adds default masks to each selected layer, then keyframes the mask shape twice: now, and KEYFRAME_DISTANCE from now. Plus position property. Then you can use the "pan behind" tool to move the layer, creating a little self-contained reveal. Neat!