change text value

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

dinyair
Posts: 1
Joined: Fri Nov 11, 2016 12:13 pm

change text value

Post by dinyair »

sorry about my english
i have a psd file named myDocument.psd
i want to change few text values when i click on button.

i need to change a 10 texts value
and then i want to save it in a new file (png file)

thanks for the helpers

Code: Select all

<button onclick="changeTextByLayerName()">Click me</button>

<script>
//get the active document


function changeTextByLayerName(layerName,newText){
var fileRef = new File("\myDocument.psd");
app.open( fileRef );
var layer = doc.layers.getByName('9542857');
if(layer.kind == LayerKind.TEXT) layer.textItem.contents = '123';
var filePath = activeDocument.fullName.path;
var pngFile = File(fileRef + "/" + "myname.png");
pngSaveOptions = new PNGSaveOptions();
doc.saveAs(pngFile, pngSaveOptions, true, Extension.LOWERCASE);
doc.close(SaveOptions.DONOTSAVECHANGES);
// close the original layered document without saving
}





</script>