David Torno has been putting together a great series on creating functions for After Effects using ExtendScript. David has likely written the definitive guide for ExtendScript witchery in After Effects, with a series of tutorials covering almost every aspect.
build a function to collect all of the precomp objects in a project.
Adding to his “Free Function Friday” series, David Torno shows how to create a function that will collect PreComps in a project. A Precomp in After Effects is a way to organize your layers not a “layer group” of sorts, and although that works in theory, it is also a way to get lost in a maze of compositions and pre-compositions.
When working in After Effects, it is important to know which compositions are being used within other compositions. After Effects will let you contextually click on an element and determine where it originates. Finding which compositions are used where can also be done with a bit of scripting, and organizing them can be the next step.
David notes an example where you are trying to organize your project into a series of folders as a great opportunity to employ some scripting magic. Check out the tutorial for Creating an After Effects Function That Will Collect PreComps here.