duplicate layer into new document with layer name
Hello all!
I'm trying to find a script that can duplicate a layer into a new document with the layer name as the new document file name. I can barely eek my way through code so I'm hoping someone here can provide a script solution.
I did find a similar post that provided the following:
function newDocFromLayer(docName,layerName){
docName == undefined ? docName = "Untitled":docName;
layerName == undefined ? layerName = activeDocument.activeLayer.name:layerName;
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( charIDToTypeID( "Dcmn" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putString( charIDToTypeID( "Nm " ), docName );
var ref1 = new ActionReference();
ref1.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "Usng" ), ref1 );
desc.putString( charIDToTypeID( "LyrN" ), layerName );
executeAction( charIDToTypeID( "Mk " ), desc, DialogModes.NO );
};
I saved this out of extendscript and ran it and nothing happens. I thought possibly because it was for an older version of Photoshop?
Thanks a billion to anyone that can read this and figure out the correct solution.