1

Is it possible to create a script for Photoshop in which, we can feed data/text to the script and update certain text layers, which have some specific name.

eg: 4 PSD templates in which some of the text layers have been named as per below.

  • First
  • Second
  • Third
  • Fourth
  • Fifth

And in this same text layers named as per above will be updated with five different texts and that needs to be repeated through all of the 4 PSD templates and as this usual, it becomes quite tiresome to update them all and not miss a text layer, that needs to be updated.

So it would be great, if anyone could help me creating a photoshop script for this.

Screenshot Please ignore the text... it's not meant for you or anyone...

  • Depends which version of Photoshop you're using, but this may be of use: http://stackoverflow.com/questions/14571008/photoshop-scripting-changing-text-of-a-text-layer – Conan May 06 '17 at 20:09

1 Answers1

1

Yes it is possible. You can create a UI panel for an edit text box. Here's the basis of what you need.

// dialogue
var dlg = new Window ("dialog", "Photoshop UI");
dlg.add ("statictext", undefined, "Do that thing");

var textContents = "No text";

// check to see if active layer is text
if (app.activeDocument.activeLayer.kind == "LayerKind.TEXT")
{
    var textItemRef = app.activeDocument.activeLayer.textItem;
    textContents = textItemRef.contents;

}

// add edit text
var edText = dlg.add ("edittext", [0,0,220,20]);
edText.text = textContents;
edText.alignment = "left";
edText.active = true;

//button group
var btnGroup = dlg.add ("group");
btnGroup.orientation = "row";
btnGroup.alignment = "center";
btnGroup.orientation = "column";

// add buttons
btnGroup.add ("button", undefined, "OK");
btnGroup.add ("button", undefined, "Cancel");
dlg.center();



var myReturn = dlg.show();


if (myReturn == 1)
{
  // set checkboxes and input here
  var ask = edText.text;
  // call the function to change text
  doThatThingThatYouDo(ask);
}


function doThatThingThatYouDo(str)
{
    // check to see if active layer is text
    if (app.activeDocument.activeLayer.kind == "LayerKind.TEXT")
    {
        var textItemRef = app.activeDocument.activeLayer.textItem;
        textItemRef.contents = str;
    }
  alert(str);
}

Create a new PSD with some text and you'll see it in action. It'll read in the text layer and allow you to change it. Hopefully You'll see how it works and use it for your own project.

Mr Mystery Guest
  • 1,464
  • 1
  • 18
  • 47
  • Thanks Mr, but I want the script to pop-up a box to update the text for that particular text layer and same for the rest of the text layers and that should open for all of PSD templates opened in Photoshop. If it's possible, please help me out here. – Ashish Eben May 08 '17 at 20:48
  • Thanks for the update, but it's only changing for only one active layer, I need it for each and every text layer named as follows with different independent text. Hoping for best .. First, Second, Third, Fourth – Ashish Eben May 13 '17 at 18:41
  • Screenshot for your refer. - https://i.stack.imgur.com/BlZjF.png - Please ignore the text... it's not meant for you or anyone... – Ashish Eben May 13 '17 at 18:46
  • 1
    Stack Overflow is not a script writing service. I have given you the basis to answer your question. There are plenty or resources on the net to help you get up to speed with javascript based photoshop scripts. – Mr Mystery Guest May 15 '17 at 07:50