16 Replies Latest reply on Nov 29, 2016 5:45 AM by Chuck Uebele

    Series of names while Cropping.

    johnandersonpixel Level 1

      Hi

           I am trying with my own action using marquee selection tool i used to select an area of an image and run the action it just crop the area and duplicates it as seperate image but with same file name copy.I want to know is there any option to save a file as jpeg in the series of continuity numbers like "1-10" with its own name via ETSK.

       

       

      For example :

       

      My images have their names like :

      784595.Q0JBHNNM.BB1.jpg,

      658589.U0JBHNKLJ.BA1.jpg.

       

      My images are always had the naming structure like this but i need it to be duplicated into separate document and naming structure as Center part of the source file name "Q0JBHNNM" and by adding the suffix from 1-10 in the file name depends upon the how many i select and run the script.

       

      (So the file names will be like Q0JBHNNM.01.jpg,Q0JBHNNM.02.jpg)

       

      Anyone help me on this.

       

      Thanks in advance.

        • 1. Re: Series of names while Cropping.
          JJMack Most Valuable Participant

          Actions have a hard time naming files they save.  Photoshop has features like Batch and Photoshop scripting that the action creator can used to help save files the manes they need. IMO  Your best option is to download and install the plug-in Image Processor Pro. Add-on. Once that is installed you can use it from bridge menu tools  and Photoshop menu File>Automate>Image Processor Pro... You can have the Image Processor process the image files you want to process and save the output File Types you need to save with the File Names you want.  Image processor pro can save many image file types and has very flexible file naming options.  For each output File you need to save you can have the Image processor include a simple action you create to customize the processing done. You can easily  do the cropping you do in you current actions and use the Image Processor file naming option to save the file with names to suit you needs.

          Capture.jpg

          • 2. Re: Series of names while Cropping.
            Chuck Uebele Adobe Community Professional & MVP

            It's best not to use "." in your file name other than for the extension. a "-" or "_" would be better. You can change the number by making a count variable or a variable in a loop then looping and incrementing the count by one eachtime:

             

             

             

            var doc = activeDocument;
            var fileBaseName = doc.name.split('.')[0];
            for(var i=1001;i<10;i++){
                 var newFileName = fileBaseName + '.' + i.toString ().substr (2) + '.jpg'
                 }
            

             

             

            Edit: corrected line 2.

            • 3. Re: Series of names while Cropping.
              johnandersonpixel Level 1

              var doc = activeDocument; 

                  var fileBaseName = doc.name.split('.') 

                 

                     // Define JPG export settings 

                  var JPGSettings = new JPEGSaveOptions(); 

                      JPGSettings.quality = 12; 

                     

                  for(var i=1001;i<10;i++){ 

                       var newFileName = fileBaseName + '.' + i.toString ().substr (2) + '.jpg'

                      

                         // Save file as JPG  

                 

                    doc.saveAs(newFileName, JPGSettings, true, Extension.LOWERCASE); 

                   

                    } 

              I have used like this but not saving as a copy of the image in series of names Can u please help me        

              • 4. Re: Series of names while Cropping.
                pixxxel schubser MVP & Adobe Community Professional

                Hi Chuck Uebele

                are you really sure, that your code works?

                 

                I think, this could be a little bit better

                var doc = activeDocument;
                var fileBaseName = doc.name.split('.');
                for(var i=1000;i<1110;i++) {
                    var newFileName = fileBaseName[1] + '_' + i.toString ().substr (1) + '.jpg';
                }
                

                 

                 

                • 5. Re: Series of names while Cropping.
                  Chuck Uebele Adobe Community Professional & MVP

                  Opps, forgot to select the first element of the array. Thanks.

                   

                  Actually, pixxxel shubser, I think in you code in line 4, you need [o] rather than [1] for selecting the base of the file name. I corrected my original script.

                  • 6. Re: Series of names while Cropping.
                    pixxxel schubser MVP & Adobe Community Professional

                    And your counter in the loop (i<10; i++ ) is a bit odd.

                    (But now the TO got two variants, with two and with three digits)

                     

                    Kindly regards

                     

                    edit (because of your edit)

                     

                    array[0] gives you 784595 but I thought Q0JBHNNM is the base name?

                    • 7. Re: Series of names while Cropping.
                      Chuck Uebele Adobe Community Professional & MVP

                      Yea, I was thinking of number 1-10, but I should have changed the loop as it will only go to 9.

                      • 8. Re: Series of names while Cropping.
                        pixxxel schubser MVP & Adobe Community Professional

                        At the end:

                        var doc = activeDocument;
                        var fileBaseName = doc.name.split('.');
                        for(var i=100; i<=110; i++) {
                            var newFileName = fileBaseName[1] + '_' + i.toString ().substr (1) + '.jpg';
                        }
                        
                        • 9. Re: Series of names while Cropping.
                          johnandersonpixel Level 1

                          it creates a snapshot in history palette but not exporting them as separate jpg files like Q0JBHNNM-01,Q0JBHNNM-02,Q0JBHNNM-03,etc

                           

                          i dont know why??

                          Here is the code whats wrong in this??

                           

                          #target photoshop

                          var doc = activeDocument; 

                          var fileBaseName = doc.name.split('.');

                              // Define JPG export settings 

                              var JPGSettings = new JPEGSaveOptions(); 

                                  JPGSettings.quality = 12; 

                           

                          for(var i=100; i<=110; i++) { 

                              var newFileName = fileBaseName[2] + '_' + i.toString ().substr (1) + '.jpg';

                              // Define new file path 

                                  var JPGName = new File(doc.path + fileBaseName[2] + '_' + i.toString ().substr (1) + '.jpg'); 

                                   

                                  // Save file as JPG 

                                  doc.saveAs(JPGName, JPGSettings, true, Extension.LOWERCASE); 

                          };

                          • 10. Re: Series of names while Cropping.
                            johnandersonpixel Level 1

                            Oops its now its working but actually what the problem is the script loops to ten times and save as a 10 different jpgs automatically but what i want to do is if i crop the area on a image and run the script it will as Q0JBHNNM-01.jpg

                            incase if crop another of same image then only the script would save the image as Q0JBHNNM-02.jpg

                             

                            Otherwise no need to save those remaining counts.

                            • 11. Re: Series of names while Cropping.
                              Chuck Uebele Adobe Community Professional & MVP

                              We just gave you the basics for creating the loop to save the files. You to add any additional code for cropping.

                              • 12. Re: Series of names while Cropping.
                                johnandersonpixel Level 1

                                Okay but the codes save the same image into ten times i just need that function to be run on save as event.

                                • 13. Re: Series of names while Cropping.
                                  johnandersonpixel Level 1

                                  can u please me how to do  that i am confused while using selection if i select an area in the image and run the image should save as 1 and if select and run the 2 nd area of my image it should save into another image as 2

                                   

                                  Please help me out !

                                  • 14. Re: Series of names while Cropping.
                                    Chuck Uebele Adobe Community Professional & MVP

                                    What all are you trying to do? When you run a script, it needs to run it's course before you can do any non repetitive editing. You can code in various things like always cropping, or making a selection. It's pretty much like an action in that regard. You can change it so it stops to let you manually set the parameters of things like cropping then continue. If you want to do a bunch of different edits then have the script save the file with the next number, you need to either create a script that stores the next number in a csv or xml file, or have all the files saved in a base folder and have the script read the names of the files to select the what would be the next one.

                                    • 15. Re: Series of names while Cropping.
                                      johnandersonpixel Level 1

                                      so if i use the above script whether it would replace the same image name or save as a different image and name.

                                      • 16. Re: Series of names while Cropping.
                                        Chuck Uebele Adobe Community Professional & MVP

                                        It should create a new file with a new name, unless you have a file already named with the first part of the file before the "." and a number 01 - 10.