2 Replies Latest reply on Jun 13, 2017 5:30 PM by ozzytheartist

    Scrip for saving as (jpeg or png) and incremental sequence name

    ozzytheartist

      Scenario:

      I'm trying to make a time lapse video.

       

      I have a finished (only one file, so no batching) drawing/painting file with many layers. I made all the layers invisible. Then, I started at my background layers and enabled the visibility of a particular layer, changed the opacity of that one layer to, lets say 25%, and saved the image as a jpeg file named "1" (however, png would be better now that I think about it). Then, I went back to the same layer, changed the opacity to 50% and saved a jpeg file as "2"........ I made it to 250 images and I cannot afford to keep going this way.

       

      Is there a script that could save the images and add a sequential name as in the example, after I have manually modified the opacity of the layer?

       

      I found this unique name command but is either not doing it or is saving the images in some random place.

       

      function CreateUniqueFileName( inFolder, inFileName, inExtension ) {

        inFileName = inFileName.replace(/[:\/\\*\?\"\<\>\|]/g, "_");  // '/\:*?"<>|' -> '_'

        var uniqueFileName = inFolder + inFileName + inExtension;

        var fileNumber = 1;

        while ( File( uniqueFileName ).exists ) {

        uniqueFileName = inFolder + inFileName + "_" + fileNumber + inExtension;

        fileNumber++;

        }

        return uniqueFileName;

      }

       

       

      I also found this code, which works but the image gets overwritten every time.

       

      var doc = app.activeDocument; 

      var Path = doc.path; 

      var Name = doc.name.replace(/\.[^\.]+$/, '');  

      var Suffix = "-Copy"; 

      var saveFile = File(Path + "/" + Name + Suffix + ".jpg"); 

      SaveJPEG(saveFile, 8); 

       

      function SaveJPEG(saveFile, jpegQuality){ 

      jpgSaveOptions = new JPEGSaveOptions(); 

      jpgSaveOptions.embedColorProfile = true; 

      jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 

      jpgSaveOptions.matte = MatteType.NONE; 

      jpgSaveOptions.quality = jpegQuality; 

      activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE); 

      }

       

       

      I wish there was something easy like (see red words):

       

      var doc = app.activeDocument; 

      var Path = doc.path; 

      var Name = doc.name.replace(/\.[^\.]+$/, '');  

      var Suffix = "i"; 

      var i=1;

      var saveFile = File(Path + "/" + Name + (Suffix+1) + ".jpg"); 

      SaveJPEG(saveFile, 8); 

       

      function SaveJPEG(saveFile, jpegQuality){ 

      jpgSaveOptions = new JPEGSaveOptions(); 

      jpgSaveOptions.embedColorProfile = true; 

      jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 

      jpgSaveOptions.matte = MatteType.NONE; 

      jpgSaveOptions.quality = jpegQuality; 

      activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE); 

      }

       

       

      I would appreciate any help. Saving: choosing the quality and renaming is taking too long. I like having the control over the opacity but I want to make the saving process faster and only focus on the opacity/transitions.

       

      Thanks!