How do I reverse this Layers Naming Loop?
I cannot figure out how to reverse a loop. I need my layers to be named numerically in the opposite order (where 0 is on the bottom instead of the top). Any help would be appreciated. I'd really like it to number everything from 1 rather than 0 but I'll figure that out later.
//-------------------------------------------------------------------- START Name Layers Numerically
#target photoshop
for (var i = 0; i < app.documents.length; i++) {
var targetDocument = app.documents[i];
var layerCount = targetDocument.layers.length;
for (var j = layerCount - 1; j >= 0; j--) {
var targetLayer = targetDocument.layers[j];
var layerName = new String(targetLayer.name);
if (layerName.indexOf(targetLayer.name) == 0) {
targetDocument.layers[j].name = j
}
}
}
//-------------------------------------------------------------------- END Name Layers Numerically
