Skip to main content
Inspiring
January 14, 2022
Answered

Script, copying text layers contents to clipboard

  • January 14, 2022
  • 1 reply
  • 1336 views

I am looking for help, for copying text layers contents to clipboard

The layers are 2 to 8 layers in the same group, named "Text"

Example of 3 text layers

//

Everything

gets better

With Time

//

I want to get at clipboard 

"Everything gets better With Time"

It is possible?

This topic has been closed for replies.
Correct answer Kukurykus

You are right, my question was not posted correctly

My solution works only because text contents and text layer name are the same...


Thank you for claricifation. Does my code works now after suggested change?

 

If you additionally don't want the result to be put to clipboard, but to the variable, change:

 

sTT = stringIDToTypeID; (dsc = new ActionDescriptor())
.putString(sTT('textData'), cntnts.join(' '))
executeAction(sTT('textToClipboard'), dsc)

 

to:

 

cntnts = cntnts.join(' ')

 

 

If that works as expected (behind sense of the request) you may mark it as correct solution 😉

1 reply

Kukurykus
Legend
January 14, 2022

 

lS = activeDocument.layerSets.getByName('Text')
tLs = [].slice.call(lS.artLayers), cntnts = []; while(tLs.length)
	cntnts.push(tLs.shift().textItem.contents); sTT = stringIDToTypeID;
(dsc = new ActionDescriptor()).putString(sTT('textData'), cntnts.join(' '))
executeAction(sTT('textToClipboard'), dsc)

 

siomospAuthor
Inspiring
January 15, 2022

Thank you!

I tried it, but the clipboard don't contains the text layers content

Kukurykus
Legend
January 15, 2022

What's your version of Photoshop? Upload / attach your 'specific' .psd to let me try on.