Search code examples
photoshopphotoshop-script

Photoshop - Increase Number in Text and Save as that Text


I am looking for a way to make me able to change/save X images so i don't have to do it manually.

So the only thing i want to change is a Text Layer which is called: Part 1#

I simply want to change the Text to Part 2# (3,4,5,6 etc).

And for every change i want to save it in .PNG as "Part 1#" "Part 2#", so the same name as the Text Layer.

I can't seem to find any information regarding this entire procedure, only automated processes of changing 1 thing, not the 2 simultaneously.

Can't provide any tries either as i haven't been able to really do anything, though i have looked around at the script, but to no avail.

Any help is appreciated.


Solution

  • Well, after 9 seconds of searching on the interweb, I found this script:

     function sfwPNG24(saveFile){
     var pngOpts = new ExportOptionsSaveForWeb;
     pngOpts.format = SaveDocumentType.PNG
     pngOpts.PNG8 = false;
     pngOpts.transparency = true;
     pngOpts.interlaced = false;
     pngOpts.quality = 100;
     activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
     }
    
     /*
     Incrementing a number inside a text layer then Saving it in PNG
     */
    
     var layer = activeDocument.layers[0];
    
     if (layer.kind == 'LayerKind.TEXT') {
     for (var i=1; i < 7; i++) {
     layer.textItem.contents = i.toString();
     sfwPNG24( 'path/where/you/want/to/save/your/files'+ i +'.png');
     };
     };
    

    Courtesy of juliend2 - https://gist.github.com/juliend2/757422

    Just change the path bit at the end and save it as a .js file somewhere, then go to File... -> Scripts -> Browse... and hey presto