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
So I am trying to take a PSD that I set up with just one text layer and append a number to the text layer and then save it as a JPG. The text layer will have text in it with a space at the end. I’ve to find something like this but currently haven’t been able to find something that will append the number and then save it as that number. Example: text layer would be “Test video “ the PsD file name would be TV.PSD. Want to to creat “Test video 1” and TV1.jpg and then do that until “Test video 100” saved as TV100.jpg all in the original folder that TV is set into.
So I have put together this and wondering if this will work (can't test it till this evening)
var OrigionalText = app.activeDocument.layers[1].textItem.contents;
var Name = decodeURI(activeDocument.name).replace(/\.[^\.]+$/, '');
var Path = decodeURI(activeDocument.path);
for(var i = 0; i<101 ; i++){
app.activeDocument.layers[1].textItem.contents = app.activeDocument.layers[1].textItem.contents + i;
var saveFile = File(Path + "/" + Name + i + ".jpg")
SaveJPEG(saveFile, 8);
app.activeDocument.layers[1].textItem.contents = OrigionalText;
}
function SaveJPEG(saveFile, jpegQuality){
var doc = activeDocument;
if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) doc.bitsPerChannel = BitsPerChannelType.EIGHT;
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
So the code worked pretty well except the layer was 0 not 1 for the text field and I adjusted the loop to start at 1 instead of 0. One last thing is the save file didn't have a space after the name which was just fine in my book.
here is the psd template, just to make sure you don't use a different psd structure...
otherwise you will need to point the script to the correct text layer index.
Sorry for being late to reply, i was very busy
Cheers,
Wasfi