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

siomospAuthor
Inspiring
January 15, 2022

No, you did not solve your problem, because you wanted the content of layers be put to clipboard. The script you linked collects layer names from text layers, not the contents. Additionally it doesn't put the result to the clipboard.

 

if you want my script worked not for text layers contents, but their names then change:

 

textItem.contents

 

to:

 

name

 

 

Tell me if that is what you needed, also what do you understand by 'clipboard' ?

 

btw according to original requirement I tried my original code on your '1.psd' and it worked. Did you for example used 'Ctrl & v' to paste the result anywhere, after running the script?


You are right, my question was not posted correctly

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