Skip to content

Instantly share code, notes, and snippets.

@Arahnoid
Forked from vladocar/layerDuplicates.js
Created July 30, 2014 23:55
Show Gist options
  • Save Arahnoid/048d0692bbc10c19ba1e to your computer and use it in GitHub Desktop.
Save Arahnoid/048d0692bbc10c19ba1e to your computer and use it in GitHub Desktop.
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