I think there are two ways:
1.Compare layer names,the duplicated has ‘copy’
2.Compare the histograms of the two layers
set other layers no visible,get current layer histograms,as follow,if two layers value is same,then get layerID ,the new Layer LayerID greater than old layer LayerID ,so "Layer 1 copy" from" Layer 1"
var r = new ActionReference(); var d = new ActionDescriptor(); r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum")); d.putReference(charIDToTypeID('null'), r); var options = executeAction(charIDToTypeID( "getd" ), d, DialogModes.NO); options=options.getList(stringIDToTypeID("histogram")); var val=""; for (var i = 0; i < options.count; i++) { var valtemp= options.getInteger(i); val=val+"\n"+valtemp; } alert(val)
the same histograms :
the different histograms :