6 Replies Latest reply on Mar 16, 2011 8:56 AM by Syasd789

    Increasing Numbers in an Action

    Syasd789

      I need to open about 800 files and write number 1 on the first, 2 on the  second, and so on. Number should be ina corner.  How would I say to the  action Write this number with this font/size/etc and then in the next  file, add one to it. Paul R. made a script but I cant find it. Any Idea? Thank you

        • 1. Re: Increasing Numbers in an Action
          Paul Riggott Level 6

          Is this the one?

           

          #target photoshop
          var inputFolder = Folder.selectDialog("Select a folder of documents to process");
          if(inputFolder) main();
          function main(){
          Count = 0;
          //This is where the output folder is created in this case its called PageNumbered
          var PathFolder = new Folder(decodeURI(inputFolder)+"/PageNumbered");
          if (PathFolder.exists == false) PathFolder.create();
          var fileList = inputFolder.getFiles(); 
          for (var i = 0; i < fileList.length; i++) {
                  var file = fileList[i];
            
          ////////////////////////////////////////////////////////////////////////////////////// 
          //Change the line below to the extention of your input files ie:
          //if the imput files are tif the line should be
          // if (file instanceof File && file.name.match(/\.tif$/i)) {
            if (file instanceof File && file.name.match(/\.jpg$/i)) {
                  open(file);
              
          doc = app.activeDocument;
          var startRulerUnits = preferences.rulerUnits
          app.preferences.rulerUnits = Units.PIXELS
          //Amend to suit.
          var fontSize = 40;
          var fontName = "Helvetica"; // NB: must be postscript name of font!
          // This is the colour of the text in RGB
          //Click foreground colour in Photoshop, choose your colour and read off the RGB values
          //these can then be entered below.
           var textColor = new SolidColor(); 
                  textColor.rgb.red  = 0; 
                  textColor.rgb.green =0; 
                  textColor.rgb.blue = 0; 
            
          var newTextLayer = doc.artLayers.add(); 
          newTextLayer.kind = LayerKind.TEXT; 
          newTextLayer.textItem.size = fontSize; 
          newTextLayer.textItem.font = fontName;
          newTextLayer.textItem.contents = ++Count; 
          newTextLayer.textItem.color = textColor; 
          newTextLayer.textItem.kind = TextType.PARAGRAPHTEXT; 
          newTextLayer.textItem.height = fontSize; 
          newTextLayer.textItem.width = doc.width -20;
          //The line below is the text position (X Y)  IE; 10 Pixels Right 10 Pixels Down
          newTextLayer.textItem.position = Array(10, 10); 
          //  Can be RIGHTJUSTFIED LEFTJUSTIFIED CENTERJUSTIFIED 
          newTextLayer.textItem.justification=Justification.LEFTJUSTIFIED; 
          doc.flatten();
          var saveFile = new File(decodeURI(PathFolder) + "/" +activeDocument.name.slice(0,-4)+".tiff"); 
          SaveTIFF(saveFile);
          activeDocument.close(SaveOptions.DONOTSAVECHANGES);
          preferences.rulerUnits = startRulerUnits;
            }
           }
          }
           
           function SaveTIFF(saveFile){
          tiffSaveOptions = new TiffSaveOptions(); 
          tiffSaveOptions.embedColorProfile = true; 
          tiffSaveOptions.alphaChannels = true; 
          tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW; 
          doc.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); 
          }
          
          • 2. Re: Increasing Numbers in an Action
            Syasd789 Level 1

            Thank you so much. It could be the one. Could you send me this script to my email (oldaricz@gmail.com)? I dont know, how save it.I can save images to tiff only?

            thank you

             

            Olda

            • 3. Re: Increasing Numbers in an Action
              Paul Riggott Level 6

              What format to you require the output files to be?

               

              To save the script all you need to do is to copy and paste the script into ExtendScript Toolkit then save it out.

              This can be found..

              PC: C:\Program Files\Adobe\Adobe Utilities
              MAC: <hard drive>/Applications/Utilities/Adobe Utilities

              • 4. Re: Increasing Numbers in an Action
                Syasd789 Level 1

                It should be for jpg format.Is it possible? Thank you so much. I will try it.

                • 5. Re: Increasing Numbers in an Action
                  Paul Riggott Level 6

                  This will save in jpeg ...

                   

                  #target photoshop
                  var inputFolder = Folder.selectDialog("Select a folder of documents to process");
                  if(inputFolder) main();
                  function main(){
                  Count = 0;
                  //This is where the output folder is created in this case its called PageNumbered
                  var PathFolder = new Folder(decodeURI(inputFolder)+"/PageNumbered");
                  if (PathFolder.exists == false) PathFolder.create();
                  var fileList = inputFolder.getFiles(); 
                  for (var i = 0; i < fileList.length; i++) {
                          var file = fileList[i];
                    
                  ////////////////////////////////////////////////////////////////////////////////////// 
                  //Change the line below to the extention of your input files ie:
                  //if the imput files are tif the line should be
                  // if (file instanceof File && file.name.match(/\.tif$/i)) {
                    if (file instanceof File && file.name.match(/\.jpg$/i)) {
                          open(file);
                      
                  doc = app.activeDocument;
                  var startRulerUnits = preferences.rulerUnits
                  app.preferences.rulerUnits = Units.PIXELS
                  //Amend to suit.
                  var fontSize = 40;
                  var fontName = "Helvetica"; // NB: must be postscript name of font!
                  // This is the colour of the text in RGB
                  //Click foreground colour in Photoshop, choose your colour and read off the RGB values
                  //these can then be entered below.
                   var textColor = new SolidColor(); 
                          textColor.rgb.red  = 0; 
                          textColor.rgb.green =0; 
                          textColor.rgb.blue = 0; 
                    
                  var newTextLayer = doc.artLayers.add(); 
                  newTextLayer.kind = LayerKind.TEXT; 
                  newTextLayer.textItem.size = fontSize; 
                  newTextLayer.textItem.font = fontName;
                  newTextLayer.textItem.contents = ++Count; 
                  newTextLayer.textItem.color = textColor; 
                  newTextLayer.textItem.kind = TextType.PARAGRAPHTEXT; 
                  newTextLayer.textItem.height = fontSize; 
                  newTextLayer.textItem.width = doc.width -20;
                  //The line below is the text position (X Y)  IE; 10 Pixels Right 10 Pixels Down
                  newTextLayer.textItem.position = Array(10, 10); 
                  //  Can be RIGHTJUSTFIED LEFTJUSTIFIED CENTERJUSTIFIED 
                  newTextLayer.textItem.justification=Justification.LEFTJUSTIFIED; 
                  doc.flatten();
                  var saveFile = new File(decodeURI(PathFolder) + "/" +activeDocument.name.slice(0,-4)+".jpg"); 
                  SaveForWeb(saveFile,80);
                  activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                  preferences.rulerUnits = startRulerUnits;
                    }
                   }
                  }
                   
                  function SaveForWeb(saveFile,jpegQuality) { 
                  var sfwOptions = new ExportOptionsSaveForWeb(); 
                     sfwOptions.format = SaveDocumentType.JPEG; 
                     sfwOptions.includeProfile = false; 
                     sfwOptions.interlaced = 0; 
                     sfwOptions.optimized = true; 
                     sfwOptions.quality = jpegQuality; //0-100 
                  activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
                  }
                   
                  
                  
                  • 6. Re: Increasing Numbers in an Action
                    Syasd789 Level 1

                    Thank you so much Mr. Paul. This script is the one and is very fast. You saved me more time.