Skip to main content
Known Participant
January 19, 2011
Answered

Can I script "duplicate" with the document name as a layers content?

  • January 19, 2011
  • 1 reply
  • 598 views

I hope that I get this across correctly.  I want to write a script that duplicates a document..That is the easy part(at least it seems like it).  The catch is I want it to be titled the contents of a specific layer name.  that layer name is static but the contents change via a data set.  Any help would greatly appreciated. If this is not a viable option I was wondering how I might go about opening a "SaveAs" dialog box with those very contents already in the "filename" box.  This seems to be out of my reach of capabilities I am quite new to scripting so again any help would be very much appreciated.

  Thanks,

     Clevadio

This topic has been closed for replies.
Correct answer Michael_L_Hale

I assume that the layer in question is a text layer and that the layer name is static.

var myLayer = app.activeDocument.layers.getByName('myLayer');// make a reference to the text layer
var layerContents = myLayer.textItem.contents;// get the layer's contents
app.activeDocument.duplicate(layerContents);// dupe with that content as name

1 reply

Michael_L_HaleCorrect answer
Inspiring
January 19, 2011

I assume that the layer in question is a text layer and that the layer name is static.

var myLayer = app.activeDocument.layers.getByName('myLayer');// make a reference to the text layer
var layerContents = myLayer.textItem.contents;// get the layer's contents
app.activeDocument.duplicate(layerContents);// dupe with that content as name

ClevadioAuthor
Known Participant
January 19, 2011

Thanks again Michael.  You are a solid fellow.

     Clevadio