3 Replies Latest reply on May 30, 2010 3:40 AM by Muppet Mark-QAl63s

    "Save as" script

    artefarct

      I want to create 100+ files with the same action. How do I incorporate this action in a script, so I can save the files with a different serial number?

      btw : I don't understand scripts and can't write them. And where can I find such a script which saves files with a serial number?

        • 1. Re: "Save as" script
          Level 7

          Have you considered using the batch command?

          • 2. Re: "Save as" script
            artefarct Level 1

            Yes, but I want to create files from scratch, and none of the options in de batch command support that, in my view.

            • 3. Re: "Save as" script
              Muppet Mark-QAl63s Level 4

              This should give you a starting point? It should make 100 file of various colours and save them numbered to folder on desktop…

               

              #target photoshop
              
              app.bringToFront();
              
              for (var i = 0; i < 100; i++) {
                   var someCol = new SolidColor();
                   someCol.rgb.red = Math.round(Math.random()*255);
                   someCol.rgb.green = Math.round(Math.random()*255);
                   someCol.rgb.blue = Math.round(Math.random()*255);
                   app.backgroundColor = someCol;
                   docRef = app.documents.add(UnitValue(100,'px'), UnitValue(100,'px'), 72, 'Foo', NewDocumentMode.RGB, DocumentFill.BACKGROUNDCOLOR);
                   // Add you commands here or Call an Action
                   var outfolder = '~/Desktop/100 Files/';
                   createFolder(outfolder);
                   var serial = zeroPad(i+1, 3);
                   var newFilePath = new File(outfolder + docRef.name + '_' + serial + '.jpg');
                saveFileasJPEG(newFilePath, 12);
                docRef.close(SaveOptions.DONOTSAVECHANGES)
              }
              
              function saveFileasJPEG(saveFile, qL) {
                jpgSaveOptions = new JPEGSaveOptions();
                jpgSaveOptions.embedColorProfile = true;
                jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
                jpgSaveOptions.matte = MatteType.NONE;
                jpgSaveOptions.quality = qL;
                activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
              }
              
              function createFolder(Directory) {
                var folderPath = new Folder(Directory);
                if (folderPath.exists == false) folderPath.create();
              }
              
              function zeroPad(num, digit) {
                var tmp = num.toString();
                while (tmp.length < digit) {tmp = '0' + tmp;}
                return tmp;
              }