2 Replies Latest reply on Nov 30, 2017 11:36 PM by catherineh79982545

    How to use Save for Web with Actions and Save a Unique Filename?

    catherineh79982545

      I recorded an action that saves opened documents using the "Save to Web" action. It works well but it only saves using the same name (eg Untitled3.jpg) How can I save them all using an incremental number or anything else that would make the filename unique?

       

      I have also tried applying a batch action to all opened files and the Starting Serial # is exactly what I need but this only applies to "Save as" actions and I would like to use "Save to Web"

        • 1. Re: How to use Save for Web with Actions and Save a Unique Filename?
          Bojan Živković Adobe Community Professional

          Have you tried to use Image Processor Pro which can save optimized images for the web. Here is my tutorial which can help you something DesignEasy: How to Add Prefix and Suffix to File Name When Batch Processing Files in Photoshop

          • 2. Re: How to use Save for Web with Actions and Save a Unique Filename?
            catherineh79982545 Level 1

            I've solved this by using the ExtendScript toolkit CS6 with this code:

             

            #target photoshop

            //alert("Hello Photoshop!");

            //app.activeDocument.activeLayer.opacity = 50;

            var randomString = function(length) {

                var text = "";

                var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

                for(var i = 0; i < length; i++) {

                    text += possible.charAt(Math.floor(Math.random() * possible.length));

                }

                return text;

            }

             

             

            var rs  = randomString(7);

             

             

            function main(){ 

            if(!documents.length) return; 

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

            var saveFile = File("c:"+ "/test/img/woman/" + rs + ".jpg"); 

            if(saveFile.exists){ 

               if(!confirm("Overwrite existing document?")) return; 

                saveFile.remove(); 

                } 

            SaveForWeb(saveFile,100); //change to 60 for 60% 

            main(); 

            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); 

            }

            and included this script into my actions.