Looking for help with text layer incrementing and saving as jpg
Posted: Sun Apr 15, 2018 5:28 pm
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)
So I have put together this and wondering if this will work (can't test it till this evening)
Code: Select all
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);
}