First-n-Last – a script to fit the comp duration to the first and last layers.

Hey, I created a script that does useful work!

It’s tedious setting the duration of a comp to fit layers that extend past the end or before the beginning, and it would be nice if you didn’t have to do the I-B-O-N + Right-click + Trim Comp To Work Area dance when you want crop a comp’s timespan to fit the length of one layer. So I created a script that does it with one click. It even has a GUI that you can dock somewhere.

My first working extendscript project, complete with A GUI, fancy that!

Download it below, then install it by putting the file in your Script_UI Panels folder which is in the After Effects application folder.

On a Mac it’s in

/Applications/Adobe/Adobe After Effects <version>/Scripts/ScriptUI Panels

on a PC it’s

C:\Program Files\Adobe\Adobe After Effects <version>\Support Files\Scripts\ScriptUI Panels


first-n-lastTo use it you go to the After Effects’ Window menu and it should appear in the list down the bottom of that menu (if you have AE running when you install it you’ll need to restart AE). It will initially open as a floating palette – you may want to dock it somewhere.

With the Trim to selected layers checkbox unchecked it will trim the comp’s in or out to the beginning of the first layer, the end of the last layer, or both. If you check the box it will trim the comp’s in-n-out to the selected layers. Really? Did I need to explain that to you? Just hit the buttons like a starving monkey in a lab cage and see what pops out of the chute, that’s what I do.

Click here to download the zip

The script is an unencrypted .jsx file, you can edit it with your favourite text editor or the Adobe Extendscript Toolkit. If you’re using an IDE or such you may have to convince it that it’s actually Javascript, or rename the file to .js temporarily. It’s released under a DWTFYWWI license, but hey, if you make a zillion bucks selling it send me a postcard from your tax haven.


click here to download


  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.


Leave a Reply

Your email address will not be published. Required fields are marked *

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