I am a Photoshop scripting beginner. I want to ask everyone how to replace the text layer in photoshop with Photoshop to read the contents of the external txt file. I am very annoyed.
First load the contents of the external text-file:
var extText = new File("path/to/external.txt");
if( extText ) {
extText.open('r');
var content = "";
while(!extText.eof) contents += extText.readln() + "\n";
extText.close();
};
Then use that the contents to update your text-layer:
var textLayer = app.activeDocument.artLayers.getByName("layer-name");
textLayer.textItem.contents = contents;
Hope this will help you feel less annoyed ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.