#target photoshop
function createnewlayer(layername1, layername2){
var idsetd = charIDToTypeID( "setd" );
var desc58 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref56 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref56.putProperty( idChnl, idfsel );
desc58.putReference( idnull, ref56 );
var idT = charIDToTypeID( "T " );
var ref57 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idTrsp = charIDToTypeID( "Trsp" );
ref57.putEnumerated( idChnl, idChnl, idTrsp );
var idLyr = charIDToTypeID( "Lyr " );
ref57.putName( idLyr, layername1 );
desc58.putReference( idT, ref57 );
executeAction( idsetd, desc58, DialogModes.NO );
var idslct = charIDToTypeID( "slct" );
var desc59 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref58 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref58.putName( idLyr, layername2 );
desc59.putReference( idnull, ref58 );
var idMkVs = charIDToTypeID( "MkVs" );
desc59.putBoolean( idMkVs, false );
executeAction( idslct, desc59, DialogModes.NO );
var idCpTL = charIDToTypeID( "CpTL" );
executeAction( idCpTL, undefined, DialogModes.NO );
}
var doc = activeDocument;
var layers_length = doc.layers.length-1;
var last_layer = doc.layers[doc.layers.length-1].name;
for(var a = 0; a < layers_length; a++) {
createnewlayer(doc.layers[a].name, last_layer);
}