-
-
Save Arahnoid/aeda4f6b78d8177a5134 to your computer and use it in GitHub Desktop.
[Sort A-Z] Sort Photoshop layers alphabeticaly #Photoshop
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
function sortLayerAZ (layerList) { | |
var layers; | |
// check if layer list is provided | |
if (layerList) { | |
layers = layerList; | |
} else { | |
layers = activeDocument.layers; | |
} | |
var len = layers.length; | |
if (len > 1) { | |
var layersArray = []; | |
// store all layers in an array | |
for (var i = 0; i < len; i++) { | |
layersArray.push(layers[i]); | |
} | |
// remove Background layer from array | |
var o = layersArray.length; | |
while(o--) { | |
if(layersArray[o].hasOwnProperty('name') && layersArray[o].name === 'Background' ) { | |
layersArray.splice(o,1); | |
} | |
} | |
// sort layer top to bottom | |
layersArray.sort(); | |
for (i = 0; i < layersArray.length-1; i++) { | |
layersArray[i].move(layers[i], ElementPlacement.PLACEBEFORE); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment