This script trims or lengthens your current comp duration to the in & out points of its contents, without affecting layer timing relative to one another.
If you have layers extending past the beginning or end of your composition, the script will extend the comp to fit them as well.
Learn More →
aescripts & aeplugins
By default, the script will trim to all layers in your comp (including locked layers), though there are options to change functionality.