Skip to content

Instantly share code, notes, and snippets.

@vladocar
Created January 17, 2012 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vladocar/1628853 to your computer and use it in GitHub Desktop.
Save vladocar/1628853 to your computer and use it in GitHub Desktop.
Layer Duplicates in Photoshop
var layerNum = app.activeDocument.layers.length;
var arr = [];
for (var i = 0; i < layerNum; i++) {
arr[i] = '"'+app.activeDocument.layers[i].name+'"';
}
// taken from: http://stackoverflow.com/questions/840781/easiest-way-to-find-duplicate-values-in-a-javascript-array
var sorted_arr = arr.sort(); // You can define the comparing function here.
// JS by default uses a crappy string compare.
var results = [];
for (var i = 0; i < arr.length - 1; i++) {
if (sorted_arr[i + 1] == sorted_arr[i]) {
results.push(sorted_arr[i]);
}
}
prompt("Layers Names:", results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment