I have a PSD Web Template with multiple PSD files and I need to replace a keyword in all of them. If I use the built-in Find & Replace it will only replace one PSD file at a time, plus it's not replacing text inside Smart Objects.
Is there any such script that can help replace a keyword from everywhere (including Smart Objects) in a PSD (also in multiple PSDs in a folder)?
The closest I found here was at Find and replace text in multiple Photoshop files?
var dir = new Folder('/c/temp')
var files = dir.getFiles("*.psd");
for (var i = 0; i < files.length; i++) {
var doc = app.open(files[i]);
for (var j= 0; j < doc.artLayers.length; j++) {
var lyr = doc.artLayers[j];
if (lyr.kind == LayerKind.TEXT) {
var lyr = doc.artLayers[j];
lyr.textItem.contents = lyr.textItem.contents.replace("search","replace");
}
}
doc.close(SaveOptions.SAVECHANGES)
}
But for some reason the script opens the PSD file and then closes it without making any changes. I tried to play the script one line at a time and it goes to line 10 (if (lyr.kind == LayerKind.TEXT) {
) and loops back to line 7 (for (var j= 0; j < doc.artLayers.length; j++) {
).