First-n-Last – a Comp Duration tool

It’s tedious trimming the length of a comp to the length of a layer, particularly if the layer extends past the beginning or end of a comp.

My first ever After Effects script makes it much easier.

Trimming comps is tedious, and if you have nested comps that you also want to extend, you have to walk your way down them all to adjust their length, and into their nested comps and so on. Apart from being soo duuull, it’s super easy to miss a nested layer somewhere, leading to unexpectedly disappearing layers.

So this is a tool that lets you do several things:

  • choose a layer or several, and then trim the comp to the last out-point and/or the first in-point of the layers.
  • For layers that are media layers (movie files etc.) you can trim to the full source length,
  • trim the start or end of the comp to the current time with one click
  • Extend any layers that currently go to the beginning / end of the comp so that they extend to the new beginning / end
  • Recurse into nested comps, extending or trimming them, so that they match the new length

One thing that it doesn’t do, because extendscript doesn’t have the capability is to zoom out the time view to the length of the newly extended comp. So if you click the button, and it looks like nothing happened, try zooming out your timeline.


Click the image to download and unzip the zip archive

Install as you would any other After Effects script.

If you have a recent version of After Effects use the File>Scripts>Install Script UI Panel menu, and after Effects will automatically put it in the right place.

Otherwise, on a PC move to the After Effects folder in the ScriptUI Panels subfolder. That’s usually:

C:\Program Files\Adobe AfterEffects <version>\Support files\scripts\ScriptUI Panels\

On a Mac it’s in the After Effects Folder in the subfolder:

 /Applications/Adobe AfterEffects <version>/scripts/ScriptUI Panels/. 


  1. Hi!

    I am extremely interested in your FirstNLast script; unfortunately, the download link seems to be dead 🙁 Would you mind updating the link on your site or alternately sending me a download link? I would greatly appreciate it.

    Also, you have a beautifully designed site.

    Thank you!


    1. Fixed the link. Hope it’s useful. There may be some bugs with the recursion function.


  2. […] first-n-last.jsx – trims the comp to the first and / or last layers, selected layers, or the current playhead position. Also lets you recursively trim and extend nested layers in a comp at the same time. […]


  3. Update trying to use on AE 2020, bug comes up – “Unable to execute script at line 179. Invalid image data.”


  4. I just installed the script on 23.6.0 and it works without a hitch.

    Stib, I’d love to buy you a beer for this. Where in Oz are you based?


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.