Modif. / Replace Text Script

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

keyman

Modif. / Replace Text Script

Post by keyman »

Hello all,

I would like to make a script to change some text inside Photoshop CS5.
I try with both JS Scripts & Actions PSD; and it does replace the text on the right layer, but the text is moved to the top left corner of the document.
I am sorry I am a real newbie about PS Scripts…
and I try to search on this forum for topic about text; but we are not able to search for this word…

Please help me if you have some links about scripting text modification / text tool / or related scripts
Thanks in advance.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Modif. / Replace Text Script

Post by Kukurykus »

It's intended for single-line text however it works for multi-lines on the condition 'next line' spaces between letters won't be changed.
Entered new multi-line text will be cut that only text from first line will be put into the layer.

For more options it's good to learn ScriptUI http://www.kahrel.plus.com/indesign/scriptui.html and RegExp http://www.rexegg.com/

Code: Select all


cnt = 'aL.textItem.contents'
if (documents.length && (aL = activeDocument.activeLayer).kind == 'LayerKind.TEXT') {
res = prompt("Edit following text:", eval(cnt)), eval(cnt + ' = res')
}
else alert("You need to have opened document with selected editable layer!")
Best to use it, is record it by action and bind to some function key.
Attachments
Text Layer Edit.zip
(489 Bytes) Downloaded 339 times