Created
March 25, 2013 12:28
-
-
Save unycone/5236786 to your computer and use it in GitHub Desktop.
This AfterEffects script sorts layers in a composition according to their in-points.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This AfterEffects script sorts layers in a composition according to their in-points. | |
* | |
* 1. Save this file as "sortlayers.jsx". | |
* 2. Select a target composition in project panel of your AfterEffects. | |
* 3. Run "sortlayers.jsx" from Menu->"File"->"Scripts"->"Run Script File". | |
*/ | |
app.beginUndoGroup("Sort layers"); | |
var item = app.project.activeItem; | |
if (item != null && item instanceof CompItem) { | |
for (var i = 1; i <= item.layers.length; ++i) { | |
var cur = i; | |
while (true) { | |
if (cur-1 > 0 && item.layers[cur].inPoint > item.layers[cur-1].inPoint) { | |
item.layers[cur].moveBefore(item.layers[cur-1]); | |
--cur; | |
} | |
else { | |
break; | |
} | |
} | |
} | |
} | |
else { | |
alert("Choose a target comp in project panel."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment