29 Replies Latest reply on Jun 6, 2014 7:07 AM by 755scrabblematt

    Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format

    755scrabblematt Level 1

      I have 2 folders of images.  One is a folder of JPEG files that have paths created for the image.  The second folder is an identical image except it is a TIFF file with no path.

       

      I have created an action that takes the path from the JPEG and places it on the TIFF and performs some work for me.  What I can't figure out is how to batch this????

       

      I am thinking i'd need a script to open the first image in each folder run the action then move onto the next image in each folder and so forth.

       

       

      Any help would be soooo wonderful.

       

      If you know of a script or can point me in a direction that would be great!

        • 1. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
          JJMack Most Valuable Participant

          This is a scripting forum not an action forum.  Your action description seems wrong to me.  You state you have two image folders. One for jpeg images and one for Tiff images. Then you go on and state in your action you take the path for the jpeg image and place it on the tiff image for tiff image has no path.  If you do that the tiff images and the jpeg images would be in the same folder not two different folders??? Also if the Tiff image is a file and not just a new open document without a backing file the backing tiff file does have a path.  Folders have paths.

           

          If you creating more then a single image file for image you may want to look into the Image Processor script that ships with Photoshop or the Image Processor Pro script that can be downloaded from Russell Brown's web site.  They can include actions recorded by you in their processing....

           

          The one that shipped with Photoshop can be found in the Bridge from menu Tools>Photoshop>Image Processor.  From Photoshop menu File>Scripts>Image Processor.

          • 2. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
            755scrabblematt Level 1

            Thanks JJMack,

             

            I do think this is a scripting question.  I only mentioned the action as to give a wholistic view of what i am trying to do. I also think there may be a little mis understanding on the path.

             

            To clarify,

             

            I have 2 identical images one is a tiff one is a jpeg.  They are in separate folders or i can put them in the sam efolder it doesn't matter. 

             

            I think i need a script that will oped the two matching images then run an action (the action requires both images open to work) then move onto the next 2 images.

             

            eg:

             

            open 001.jpg and 001.tiff - run action

            open 002.jpg and 002.tiff - run action

            .....

             

            I hope this clarifys things a little more.

            • 3. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
              JJMack Most Valuable Participant

              Yes you would need to write a script to do that.  The script would need to have a dialog or prompt for the input folders.  If  a single folder file with the same name should sort together. In any case the script would need to retrieve a files list(s) and match file names and logic to skip files that can not be paired. Script have no problem retrieving file list and running actions on open files.  Action the require two open files may have a problem switching between files it there are more then two documents open

               

              For your example if the sequence  Open 001.jpeg, open 001.tif do action.  001.tif would be the active document when the action starts to run. 001.jpeg would be previous or next document Photoshop document chain  links the first and last so if you step off the last document in a forward next step you fall on the first document and if you step backwards previous step off the first you land on the last. Care must also be exercised if in action play an other for action can add to the document ring opening files or creating additional document. Design your action process well. All Saving should be done back in the script after the action does its work. Script can use logic in the save process.

               

              If you do not have programming skills you will have a hard time. There are a lot of script example in this forum.  You can find example that  get list of file in a folder it would also be possible to get a list of jpeg files in a folder as will as a list of tiff files in a folder.  You can also sort file list scripting is programming its work.

               

              Message was edited by: JJMack

              • 4. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                755scrabblematt Level 1

                is this something you could help write for me?  Or know anyone that could help write for me?

                • 5. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                  JJMack Most Valuable Participant

                  What you wrote does not make a lot of sense to me.

                  I have 2 folders of images.  One is a folder of JPEG files that have paths created for the image.  The second folder is an identical image except it is a TIFF file with no path.

                  I have created an action that takes the path from the JPEG and places it on the TIFF and performs some work for me.  What I can't figure out is how to batch this????

                   

                  The second folder is an identical image except it is a TIFF file with no path. A folder has a path.

                   

                  I have created an action that takes the path from the JPEG and places it on the TIFF and performs some work for me. Actions can not use logic to do something like modify a path. It sounds more like you process a jpeg file and save a TIFF file into the Jpeg file path. 

                   

                  If that is what you have done is you should be able to batch that action using menu File>Automate>Batch and in the batch dialog use the override save as steps. However batch can not just select jpeg image from a folder all files will be processed.

                   

                  If you are processing a single folder of images and want to save modified image version as tiff files into a second folder you should look into the Image Processor script that ships with Photoshop menu File>Scripts>Image Processor,   or look at the Image Processor Pro plug-in that can be downloaded from Russell Browns web site.

                   

                  If you have two source folders of images you would need a script.  You would need to design the process to handle any situation that could happen like there are missing files like the next tiff filename does not match the jpeg filename just open. Does this mismatch indicate the missing file is actually a jpeg is missing for the next Tiff filename sorts lower then the jpeg filename just opened.

                   

                  In any case I think you need to describe what you want to do better then what you have posted here

                  • 6. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                    755scrabblematt Level 1

                    I know i need a script.  I will be a little more exact hopfully this may make sense.

                     

                    Folder A has jpeg images in it and the images have paths drawn around an item in the image

                    Folder B is the same photo but the file is a TIFF file.  The tiff file has the same dimentions as the JPEG file but there is no path on this file. 

                     

                    I need to transfer the path from the images in folder A to the images in folder B

                     

                     

                    So 001.jpg has a path that i need to put on 001.TIFF

                     

                    I have already built an action that does this.  I have to have both files open at once and the action works.  I can do this manually but to do this to 100+ images takes too much time.  I want it austomate.

                     

                    Hense the need for a script to open file 001.jpg then open file 001.TIFF then run the action, then open 002.jpg then option 002.TIFF then run the action ....etc.

                     

                    Hope this makes sense.

                    • 7. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                      755scrabblematt Level 1

                      I think this thread outlines best what i am needing.  I believe the reference to path has been confused with the location of a file.  when i have spoken of a path i meant a clipping path. a vector path in photoshop.

                       

                       

                      I have 2 identical images one is a tiff one is a jpeg.  They are in separate folders or i can put them in the sam efolder it doesn't matter. 

                       

                      I think i need a script that will oped the two matching images then run an action (the action requires both images open to work) then move onto the next 2 images.

                       

                      eg:

                       

                      open 001.jpg and 001.tiff - run action

                      open 002.jpg and 002.tiff - run action

                      .....

                       

                      I hope this clarifys things a little more.

                      • 8. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                        JJMack Most Valuable Participant

                        Then you need a script which is a program. Before you can have a program you need a design that can handle error situations like jpeg with a missing path or a missing jpeg or missing tiff file.  Once you have a good design you can program it. As you state your not a programmer or designer.  I'm sure you can do 100 by hand faster then you can become a designer and programmer.  I can not imagine that you would be willing to pay a lot just to process 100 image one time.

                        • 9. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                          755scrabblematt Level 1

                          This is somethign that i have to do many times over.  Can you help?

                          • 10. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                            JJMack Most Valuable Participant

                            I'm not for heir and not that good at Photoshop scripting.  Many thing can be handled in scripting that can not be done in actions. If all you want to do is to copy a path from one file to and other an action may not even be needed. Running an Action from a script is easy but it add complication to the script. Do you want to be able to select the script then the script needs a dialog needs to retrieve all the current action sets loaded to provide a pull down menu for action set then it needs to retrieve all the actions in the selected set for a pull down menu to select the action. If not selectable then its hare wired and the script depends on the action set being laded and the set contain the action. Programming is not something simple like recording an action.  You also need to describe exactly in Photoshop terms what the jpeg and tiff documents look like. While a jpeg file can have a path in it. It can not have a clipping mask for Jpeg files do not support layers with transparency just a background layer.  Tiff files do support layers so they can have clipping mask both vector an raster types. The same image can also be saved flattened tiff file. Also post what your willing to pay. This is not a job for me.

                            • 11. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                              Paul Riggott Level 6

                              This is untested but should be close.

                              It assumes that your action will do what it should, save the output and closes the files!

                              You will need to amend the code with your action name and action set...

                               

                               

                              #target photoshop
                              main();
                              function main(){
                              var jpgFolder = Folder.selectDialog("Please select the jpg folder");
                              if( jpgFolder == null) return;
                              var tifFolder = Folder.selectDialog("Please select the tif folder");
                              if( tifFolder == null) return;
                              var fileList = jpgFolder.getFiles("*.jpg");
                              for(var a in fileList){
                                  var JPG = fileList[a];
                                  var TIF = File( tifFolder + "/" + fileList[a]name.toString().replace(/jpg$/i,'tif'));
                                  if(!TIF.exists) continue;
                                  open(JPG);
                                  open(TIF);
                                  //needs amending with your action name and actionset
                                  doAction("ActionName","ActionSet");
                                  }
                              };
                              
                              
                              1 person found this helpful
                              • 12. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                755scrabblematt Level 1

                                Thanks i'd love to try this.

                                 

                                As you may realise i am no programmer.  What do i do with this to make it run?  Plug it into photoshop somewhere or how?

                                • 13. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                  Paul Riggott Level 6

                                  The script needs to be saved in plain text with an extension of jsx

                                  The best thing is to use ExtendScript Toolkit, this gets installed with Photoshop.

                                  The script needs to be saved in the applications Presets/Scripts folder I.E.

                                  C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts

                                  N.B. If you are using Vista or Windows 7/8 you will need to save the script somewhere else and copy it to the correct folder. This is due to premissions.

                                   

                                  Once the script has been saved, close and re-start Photoshop

                                  To use:-

                                  File - Scripts - select the script

                                   

                                  Hope it helps.

                                  1 person found this helpful
                                  • 14. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                    JJMack Most Valuable Participant

                                    To comply with what Paul wrote you will probably have to add two Close NO Save steps to the end of you action. Also Note Paul did not put out an error message if a tiff file is missing the process either skips to then next jpeg or ends.  There is also no test for a tiff file that may have a missing jpeg the script just process jpeg files and looks for matching tiff files.  If all thing are correct this should work well for you. When your action get control the TIFF file should be the current document you action will need to select previous to get the path. In the Script you need to change  "ActionName","ActionSet"


                                    • 15. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                      755scrabblematt Level 1

                                      finally got to check and see if this is going to work.

                                       

                                      Thanks for writing it for me but when i run the script is says the following

                                       

                                      Error 25: Expected: ).

                                      Line: 11

                                      ->      var TIF = File( tifFolder + "/" + fileList[a]name.toString().replace(/jpg$/i,'tif'));

                                       

                                       

                                      any thoughts?

                                      • 16. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                        Paul Riggott Level 6

                                        Sorry about that, I had missed a fullstop out of that line, please try this now.

                                         

                                         

                                        #target photoshop
                                        main();
                                        function main(){
                                        var jpgFolder = Folder.selectDialog("Please select the jpg folder");
                                        if( jpgFolder == null) return;
                                        var tifFolder = Folder.selectDialog("Please select the tif folder");
                                        if( tifFolder == null) return;
                                        var fileList = jpgFolder.getFiles("*.jpg");
                                        for(var a in fileList){
                                            var JPG = fileList[a];
                                            var TIF = File( tifFolder + "/" + fileList[a].name.toString().replace(/jpg$/i,'tif'));
                                            if(!TIF.exists) continue;
                                            open(JPG);
                                            open(TIF);
                                            //needs amending with your action name and actionset
                                            doAction("ActionName","ActionSet");
                                            }
                                        };
                                        
                                        
                                        • 17. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                          755scrabblematt Level 1

                                          It works!!!!  THANK YOU SO MUCH!

                                           

                                          can i make a donation to you for your help?

                                          • 18. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                            Paul Riggott Level 6

                                            Thanks but everything here is free. Glad it works and saves you a bit of time.

                                            1 person found this helpful
                                            • 19. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                              755scrabblematt Level 1

                                              this script has been wonderful and saved me hours of work.  I have found however that it doesn't work on an attached external hard drive?  The folders have to be local.

                                               

                                              Is there a way to tweek it so it will work on external attached drives (usb or firewire)?

                                              • 20. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                JJMack Most Valuable Participant

                                                How is the script failing on the external drive?  Do your files have lower case extensions .jpg and .tif? Some File System are case sensitive. I do not think windows FS is but Apple's unix file system may be. Do any files open? If so does your action get control?  To me it looks like it should work.  

                                                • 21. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                  Paul Riggott Level 6

                                                  As JJ has said it should work, could it be a problem in your action?

                                                  • 22. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                    755scrabblematt Level 1

                                                    so what happens is nothing.  Nothing happens.  no opening of any images, No errors.  no nothing.  i have tried with the script located on the drive and all alternative options but the only way  i find it to work is to have the folders for the jpegs and tiffs on the local hard drive.

                                                     

                                                    here are the steps of the action:

                                                     

                                                    set selection to all

                                                    copy

                                                    close without saving

                                                    paste

                                                    merge visible

                                                    save.

                                                     

                                                     

                                                    so basically as the tiff is the last image to open it is the active file i copy the image then paste it onto the JPEG that has the path then merge and save it as a tiff file.

                                                     

                                                    Any thoughts????

                                                    • 23. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                      Paul Riggott Level 6

                                                      It looks as if the Tif file is not found, could you try this on a coulple of test folders and see if it gives an error message.

                                                       

                                                       

                                                      #target photoshop
                                                      main();
                                                      function main(){
                                                      var jpgFolder = Folder.selectDialog("Please select the jpg folder");
                                                      if( jpgFolder == null) return;
                                                      var tifFolder = Folder.selectDialog("Please select the tif folder");
                                                      if( tifFolder == null) return;
                                                      var fileList = jpgFolder.getFiles("*.jpg");
                                                      for(var a in fileList){
                                                          var JPG = fileList[a];
                                                          var TIF = File( tifFolder + "/" + fileList[a].name.toString().replace(/jpg$/i,'tif'));
                                                          if(!TIF.exists){
                                                              alert(decodeURI(TIF) + " Does not exists");
                                                              continue;
                                                              }
                                                          open(JPG);
                                                          open(TIF);
                                                          //needs amending with your action name and actionset
                                                          doAction("ActionName","ActionSet");
                                                          }
                                                      };
                                                      
                                                      

                                                       

                                                      I am not sure about your action as after you have closed the tif file and pasted it onto the jpg a save would save as a jpg not a tif?

                                                      1 person found this helpful
                                                      • 24. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                        755scrabblematt Level 1

                                                        Ok thanks for working on this with me.

                                                         

                                                        Here is what i found.

                                                         

                                                        The new script at first gave me a file not found message.

                                                         

                                                        I then changed the extension to be .tif instead of .TIF and then it worked.

                                                         

                                                        So it looked like it was case sensitive.  Is there a way to have it run on .tif and .TIF?

                                                         

                                                        If i am getting too involved here please tell me. 

                                                         

                                                        But thanks for your help.

                                                        • 25. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                          JJMack Most Valuable Participant

                                                          Not to involved.  You now have a better understanding what I meant by designing the process and I wrote that Paul's script should work if all is correct and that if the tif file is not found no error is outputted it just skips to the next jpeg or ends if no more jpg files.   A file system that is case sensitive can have more the one  jpeg and more then one tiff file for a given file name all can reside in the same folder this is not the case on a windows system its case insensitive.  The only time I need to deal with case is when I upload files to my Linux web file server.   There are differences between Mac and PC I gave my son some of my scripts and they did not work on his mac.  Others  had reported my scripts work on their Mac.  It tured out to be that mac users use some different file extensions for jpeg and tiff file.  Mac users use .jpg, jpe, .jpeg, .tif and .tiff.  My script only had .jpg and .tif.  I have since added the other extensions.  However I did not add case support for i think by default the .getFiles method is not case sensitive.

                                                           

                                                          What should the script do if the file system is case sensitive for the file.exists statement Name.jpg Name.tif Name.Tif Name.TIF Name.tiff all exists? How do you want to handle this or does first found tiff file win. This may do that if all jpeg files are .jpg. While the code I changed may find .jpe and .jpeg the string replace code will not work but for .jpg.   The case of .tif and .TIF should work however .Tif .tiff  etc will not be found.

                                                           

                                                          #target photoshop

                                                          main();

                                                          function main(){

                                                          var jpgFolder = Folder.selectDialog("Please select the jpg folder");

                                                          if( jpgFolder == null) return;

                                                          var tifFolder = Folder.selectDialog("Please select the tif folder");

                                                          if( tifFolder == null) return;

                                                          var fileList = jpgFolder.getFiles(/\.(jpg|jpe|jpeg)$/i);

                                                          for(var a in fileList){

                                                              var JPG = fileList[a];

                                                              var TIF = File( tifFolder + "/" + fileList[a].name.toString().replace(/jpg$/i,'tif'));

                                                              if(!TIF.exists){

                                                                  var TIF = File( tifFolder + "/" + fileList[a].name.toString().replace(/jpg$/i,'TIF'));

                                                                   if(!TIF.exists){

                                                                      alert(decodeURI(TIF) + " Does not exists");

                                                                      continue;

                                                                      }

                                                                  }

                                                              open(JPG);

                                                              open(TIF);

                                                              //needs amending with your action name and actionset

                                                              doAction("ActionName","ActionSet");

                                                              }

                                                          };

                                                           

                                                          Message was edited by: JJMack

                                                          • 26. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                            Paul Riggott Level 6

                                                            I have done a few test here but I'am afraid that I can't reproduce the error, all the tests that have been done work with any case, with servers, attached drives and memory sticks.

                                                            My tests have been using Windows 7.

                                                            I wonder if there is something different with your drive setup?

                                                            • 27. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                              JJMack Most Valuable Participant

                                                              Yes Windows File names are case insensitive.  The Name and extension may contain mixed case but only on file name can exist with a particular character string regardless of case. Unix file systems are case sensitive. I have to pay close attention to case when I upload files to my Linux Web server they must have the same case I code in my html be an exact match. If he is on a Mac Apple's OS is a Unix based OS and its file system file names may well be case sensitive.   File.exists may be case sensitive.   I do not think that Folder.getFiles("*.jpg") is for sure on a windows system it would return  a file Name.jpg or Name.JPG or Name.Jpg or Name.jPg or Name.jpG etc.  On a Unix system it may return all of those since names are case sensitive and all those file can exist in a folder.  Where on a Windows files system only one of those name can exist in a folder.

                                                               

                                                              It may help if the OP states what OS version he is running on PC|Mac    I use PC XP and Win 7

                                                              • 28. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                                yashijoon

                                                                I test it when type my action name and action set had error

                                                                • 29. Re: Script to open 2 versions of the same file one JPEG and one TIFF - the nrun action in a batch format
                                                                  755scrabblematt Level 1

                                                                  G'day Paul,

                                                                   

                                                                  I want to thank you again for the script you helped me with some time back.  This has been so useful.  Thanks!