24 Replies Latest reply on Dec 8, 2011 9:16 PM by Ian___

    Batch process RAW exposures, please help!

    Ian___

      Hello, I'm new to photoshop scripting for windows, and I was wondering if anyone knew how to batch process a folder of raw files, change the the raw's exposure, and save as jpg to another folder, based on a condition within the file's name, then close the opended jpg  document.

       

      My goal is to have a script that extracts the correct exposures from sets of three bracketed raw files, which I usually have seperated by 2 EV's.  So for example, say I have a folder Called Batch Processing on the C drive, and I have two folders,

       

      C:\Batch Processing\JPG

      C:\Batch Processing\RAW

       

      and in the RAW folder I have some files called,

       

      Image_01_E01.cr2

      Image_01_E02.cr2

      Image_01_E03.cr2

       

      If the file has "_E01" at the end, I want to open that raw file, change the exposure to -4, save the file with the same name, except the last 4 characters, and add some number to the end, so for example, it would end up being "Image_01" + "_E01".  This would end up being saved to the JPG folder. Then open up the same file, change the exposure to -2 and save as "Image_01" + "_E02".

       

      To make this post short, here is the conversion table I'm trying to achieve -

       

      Image_01_E01.cr2 -> Image_01_E01.jpg Exposure = -4

      Image_01_E01.cr2 -> Image_01_E02.jpg Exposure = -2

      Image_01_E02.cr2 -> Image_01_E03.jpg Exposure = -2

      Image_01_E02.cr2 -> Image_01_E04.jpg Exposure = 0

      Image_01_E02.cr2 -> Image_01_E05.jpg Exposure = 2

      Image_01_E03.cr2 -> Image_01_E06.jpg Exposure = 2

      Image_01_E03.cr2 -> Image_01_E07.jpg Exposure = 4

       

      After that, close all open files. Then, if there is another set of raws, repeat for them as well. For example -

       

      Image_02_E01.cr2 -> Image_02_E01.jpg Exposure = -4

      Image_02_E01.cr2 -> Image_02_E02.jpg Exposure = -2

      Image_02_E02.cr2 -> Image_02_E03.jpg Exposure = -2

      Image_02_E02.cr2 -> Image_02_E04.jpg Exposure = 0

      Image_02_E02.cr2 -> Image_02_E05.jpg Exposure = 2

      Image_02_E03.cr2 -> Image_02_E06.jpg Exposure = 2

      Image_02_E03.cr2 -> Image_02_E07.jpg Exposure = 4

       

      So basically this script would take 3 raws seperated by 2 EV's and extract 7 exposures, seperated by 2 EV's.  I've done this manually, and merged them to hdr, and the results are actually pretty decent. 

       

      I tried doing this with actions and batch processing, but I had to have everything seperated in individual folders like E01, E02, etc. and I had to make an action for each step in the process.

       

      I know this is probably a lot to ask, but I think it can be done, and I would of course credit the person in the script for helping.

       

      Thanks in advance!

        • 1. Re: Batch process RAW exposures, please help!
          Paul Riggott Level 6

          Hi Ian, this might be better done in Bridge. Could you let me know what version of Photoshop you have as it would require CS4 or better to do this in Bridge.

          • 2. Re: Batch process RAW exposures, please help!
            Paul Riggott Level 6

            Ok I am assuming you have CS4 or better...

             

            Copy and paste the script into ExtendScript Toolkit
            This gets installed with Photoshop and can be found:-
            PC: C:\Program Files\Adobe\Adobe Utilities
            MAC: <hard drive>/Applications/Utilities/Adobe Utilities

            Start Bridge
            PC: Edit - Preferences - Startup Scripts
            Mac: Adobe Bridge menu - Preferences - Startup Scripts
            At the bottom click the "Reveal Button" this will open the folder where the script should be saved.
            Close and restart Bridge.
            Accept the new script.

            To use:-
            Navigate to the folder with your CR2 files, then Tools - "CR2 to Seven JPGs"
            Go get a coffee.

             

             

            #target bridge   
               if( BridgeTalk.appName == "bridge" ) {  
            CR2JPG = MenuElement.create("command", "CR2 to Seven JPGs", "at the end of Tools");
            }
            CR2JPG.onSelect = function () { 
            var progressBar = function(title) {
            var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
            pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
            st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
            st.justify = 'center';
            w.center();
            this.reset = function( msg,maxValue ) {
            st.text = msg;
            pb.value = 0;
            pb.maxvalue = maxValue||0;
            pb.visible = !!maxValue;
            w.show();
            };
            this.hit = function() { ++pb.value; };
            this.hide = function() { w.hide(); };
            this.close = function() { w.close(); };
            this.show = function() { w.show(); };
            this.update = function() { w.update(); };
            this.layout = function() { w.layout.layout(); };
            };
            function doPbar(){
            pBar.hit();
            pBar.hide();
            pBar.show();
                }
            var count = 0;
            var Path = Folder(app.document.presentationPath);
            var group1 = Path.getFiles(/\e01.cr2$/i);
            var group2 = Path.getFiles(/\e02.cr2$/i);
            var group3 = Path.getFiles(/\e03.cr2$/i);
            count += group1.length;
            count += group2.length;
            count += group3.length;
            var jpgFolder = Folder(Path+"/JPG");
            if(!jpgFolder.exists) jpgFolder.create();
            if(count <1) return;
            var pBar = new progressBar("CR2 to Seven JPGs");
            pBar.reset("Processing E01 Files", (group1.length*2));
            for(var a in group1){
            var thumb = new Thumbnail(group1[a]);
            var Name = decodeURI(group1[a].name).replace(/\.[^\.]+$/, '');
            Name = Name.replace(/e01$/i,'');
            group1Exposure = setEV(group1[a],-4);
            var BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E01.jpg" );
            BM.exportTo( exportFile,  100);
            doPbar();
            setEV(group1[a],-2);
            BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E02.jpg" );
            BM.exportTo( exportFile,  100);
            setEV(group1[a],group1Exposure);
            doPbar();
                }
            pBar.reset("Processing E02 Files", (group2.length*3));
            for(var b in group2){
            var thumb = new Thumbnail(group2[b]);
            var Name = decodeURI(group2[b].name).replace(/\.[^\.]+$/, '');
            Name = Name.replace(/e02$/i,'');
            group2Exposure = setEV(group2[b],-2);
            var BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E03.jpg" );
            BM.exportTo( exportFile,  100);
            doPbar();
            setEV(group2[b],-2);
            BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E04.jpg" );
            BM.exportTo( exportFile,  100);
            doPbar();
            setEV(group2[b],0);
            BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E05.jpg" );
            setEV(group2[b],2);
            BM = createBM(thumb);
            BM.exportTo( exportFile,  100);
            setEV(group2[b],group2Exposure);
            doPbar();
                }
            pBar.reset("Processing E03 Files", (group3.length*2));
            for(var c in group3){
            var thumb = new Thumbnail(group3[c]);
            var Name = decodeURI(group3[c].name).replace(/\.[^\.]+$/, '');
            Name = Name.replace(/e03$/i,'');
            group2Exposure = setEV(group3[c],2);
            var BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E06.jpg" );
            BM.exportTo( exportFile,  100);
            doPbar();
            setEV(group3[c],2);
            BM = createBM(thumb);
            var exportFile = new File( jpgFolder + "/" + Name + "E07.jpg" );
            setEV(group3[c],4);
            BM = createBM(thumb);
            BM.exportTo( exportFile,  100);
            setEV(group3[c],group2Exposure);
            doPbar();
                }
            pBar.close();
            function setEV(thumb,evValue){
            var Name = decodeURI(new Thumbnail(thumb).spec.name).replace(/\.[^\.]+$/, '');
            var file = new File(new Thumbnail(thumb).spec.path +"/" +Name +".xmp");
            try{
            if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
              if(file.exists){
                 file.open('r');
                 file.encoding = "UTF8";
                 file.lineFeed = "unix"; 
                 file.open("r", "TEXT", "????");
                 var xmpStr = file.read();
                 file.close();
                 }else{
                     var xmpStr='';
                     }
                 var xmp = new XMPMeta( xmpStr );
                var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                xmp.setProperty(XMPConst.NS_CAMERA_RAW, "Exposure",Number(evValue)); 
                 file.open('w');
                 file.encoding = "UTF8";
                 file.lineFeed = "unix"; 
                 file.write( xmp.serialize() );
                 file.close();
                 if(exposureValue  == undefined) exposureValue = 0;
                 }catch(e){alert(e+"-"+e.line);}
                 return exposureValue;
            };
            function createBM(thumb){
            var sourceBitmap = undefined;
            app.synchronousMode = true;
            sourceBitmap = thumb.core.fullsize.fullsize; 
            app.synchronousMode = false; 
            sourceBitmap = sourceBitmap.rotate(thumb.rotation);
            return sourceBitmap;
                }
            };
            
            
            
            • 3. Re: Batch process RAW exposures, please help!
              Ian___ Level 1

              WOW, thanks for the reply, I am using CS5. I'll definitely give this a try. My goal is to have everything dealing with hdr in droplets, whether they are scripts or actions. I'll have to break down this script and figure out how it works, because also plan on making different permutations of it, such as converting 9 exposures from 5 raws, or getting 3 exposures from a single raw. If you want, I can post a bracketing chart from excel I made, that has different conversion variations from raws. This chart is assuming that you can get +-4 EV for the exposure. How do you make an attachment here?

               

              Thanks again for your help, -Ian

              • 4. Re: Batch process RAW exposures, please help!
                Ian___ Level 1

                Oh, BTW, I was also wondering how you would batch those resulting exposures using Merge to HDR Pro with default settings, into hdr files, with the corresponding file names, so that the files would end up being called Image_01.hdr, Image_02.hdr, etc. in a folder called HDR. The path would be C:\Batch Processing\HDR

                 

                Im sure this would be pretty tricky as well, but its probably nothing your mighty scripting skills couldn't handle. 

                • 5. Re: Batch process RAW exposures, please help!
                  Paul Riggott Level 6

                  Hi Ian, I have never worked with HDR, Mike has done some work on these though and might chip in.

                  http://forums.adobe.com/thread/653485?tstart=0

                   

                  As for running droplets, that would not be possible with the script above as everything is done in Bridge, Photoshop is not involved in any way.

                  I don't think you can add an attachment but you can add a link to somewhere where it can be downloaded.

                  • 6. Re: Batch process RAW exposures, please help!
                    Ian___ Level 1

                    Hey Paul, I'm not sure if its your script, or if its because of the xmp settings file that's created by the raw files, but some of the exposures that are created are the same. I think the script is saving the first exposure values choosen for each file.

                     

                    For example the exposures are saved as follows -

                     

                    Image_01_E01.cr2 -> Image_01_E01.jpg Exposure = -4

                    Image_01_E01.cr2 -> Image_01_E02.jpg Exposure = -4

                    Image_01_E02.cr2 -> Image_01_E03.jpg Exposure = -2

                    Image_01_E02.cr2 -> Image_01_E04.jpg Exposure = -2

                    Image_01_E02.cr2 -> Image_01_E05.jpg Exposure = -2

                    Image_01_E03.cr2 -> Image_01_E06.jpg Exposure = 2

                    Image_01_E03.cr2 -> Image_01_E07.jpg Exposure = 2

                     

                    Maybe each xmp file has to be deleted after each jpg file is saved from the script. Please let me know what your thoughts are on this as soon as you can, thanks in advance, - Ian

                    • 7. Re: Batch process RAW exposures, please help!
                      Paul Riggott Level 6

                      Ah, I found a couple of errors in the code which have now been corrected, could you try this now....

                       

                       

                      #target bridge   
                         if( BridgeTalk.appName == "bridge" ) {  
                      CR2JPG = MenuElement.create("command", "CR2 to Seven JPGs", "at the end of Tools");
                      }
                      CR2JPG.onSelect = function () { 
                      var progressBar = function(title) {
                      var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
                      pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
                      st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
                      st.justify = 'center';
                      w.center();
                      this.reset = function( msg,maxValue ) {
                      st.text = msg;
                      pb.value = 0;
                      pb.maxvalue = maxValue||0;
                      pb.visible = !!maxValue;
                      w.show();
                      };
                      this.hit = function() { ++pb.value; };
                      this.hide = function() { w.hide(); };
                      this.close = function() { w.close(); };
                      this.show = function() { w.show(); };
                      this.update = function() { w.update(); };
                      this.layout = function() { w.layout.layout(); };
                      };
                      function doPbar(){
                      pBar.hit();
                      pBar.hide();
                      pBar.show();
                          }
                      var count = 0;
                      var Path = Folder(app.document.presentationPath);
                      var group1 = Path.getFiles(/\e01.cr2$/i);
                      var group2 = Path.getFiles(/\e02.cr2$/i);
                      var group3 = Path.getFiles(/\e03.cr2$/i);
                      count += group1.length;
                      count += group2.length;
                      count += group3.length;
                      var jpgFolder = Folder(Path+"/JPG");
                      if(!jpgFolder.exists) jpgFolder.create();
                      if(count <1) return;
                      var pBar = new progressBar("CR2 to Seven JPGs");
                      pBar.reset("Processing E01 Files", (group1.length*2));
                      for(var a in group1){
                      var thumb = new Thumbnail(group1[a]);
                      var Name = decodeURI(group1[a].name).replace(/\.[^\.]+$/, '');
                      Name = Name.replace(/e01$/i,'');
                      group1Exposure = setEV(group1[a],-4);
                      var BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E01.jpg" );
                      BM.exportTo( exportFile,  100);
                      doPbar();
                      setEV(group1[a],-2);
                      BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E02.jpg" );
                      BM.exportTo( exportFile,  100);
                      setEV(group1[a],group1Exposure);
                      doPbar();
                          }
                      pBar.reset("Processing E02 Files", (group2.length*3));
                      for(var b in group2){
                      var thumb = new Thumbnail(group2[b]);
                      var Name = decodeURI(group2[b].name).replace(/\.[^\.]+$/, '');
                      Name = Name.replace(/e02$/i,'');
                      group2Exposure = setEV(group2[b],-2);
                      var BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E03.jpg" );
                      BM.exportTo( exportFile,  100);
                      doPbar();
                      setEV(group2[b],0);
                      BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E04.jpg" );
                      BM.exportTo( exportFile,  100);
                      doPbar();
                      setEV(group2[b],2);
                      BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E05.jpg" );
                      BM.exportTo( exportFile,  100);
                      setEV(group2[b],group2Exposure);
                      doPbar();
                          }
                      pBar.reset("Processing E03 Files", (group3.length*2));
                      for(var c in group3){
                      var thumb = new Thumbnail(group3[c]);
                      var Name = decodeURI(group3[c].name).replace(/\.[^\.]+$/, '');
                      Name = Name.replace(/e03$/i,'');
                      group2Exposure = setEV(group3[c],2);
                      var BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E06.jpg" );
                      BM.exportTo( exportFile,  100);
                      doPbar();
                      setEV(group3[c],4);
                      BM = createBM(thumb);
                      var exportFile = new File( jpgFolder + "/" + Name + "E07.jpg" );
                      BM.exportTo( exportFile,  100);
                      setEV(group3[c],group2Exposure);
                      doPbar();
                          }
                      pBar.close();
                      function setEV(thumb,evValue){
                      var Name = decodeURI(new Thumbnail(thumb).spec.name).replace(/\.[^\.]+$/, '');
                      var file = new File(new Thumbnail(thumb).spec.path +"/" +Name +".xmp");
                      try{
                      if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
                        if(file.exists){
                           file.open('r');
                           file.encoding = "UTF8";
                           file.lineFeed = "unix"; 
                           file.open("r", "TEXT", "????");
                           var xmpStr = file.read();
                           file.close();
                           }else{
                               var xmpStr='';
                               }
                           var xmp = new XMPMeta( xmpStr );
                          var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                          xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                          xmp.setProperty(XMPConst.NS_CAMERA_RAW, "Exposure",Number(evValue)); 
                           file.open('w');
                           file.encoding = "UTF8";
                           file.lineFeed = "unix"; 
                           file.write( xmp.serialize() );
                           file.close();
                           if(exposureValue  == undefined) exposureValue = 0;
                           }catch(e){alert(e+"-"+e.line);}
                           return exposureValue;
                      };
                      function createBM(thumb){
                      var sourceBitmap = undefined;
                      app.synchronousMode = true;
                      sourceBitmap = thumb.core.fullsize.fullsize; 
                      app.synchronousMode = false; 
                      sourceBitmap = sourceBitmap.rotate(thumb.rotation);
                      return sourceBitmap;
                          }
                      };
                      
                      
                      
                      • 8. Re: Batch process RAW exposures, please help!
                        Ian___ Level 1

                        Thanks for trying Paul, unfortunately the results are the same.  This script gets saved as a jsx file right? Does it have to be saved from extendscript? I used a seperate text editor called PSPad which supports multi syntax highlighting including javascript.

                         

                        Here's a link to a zip file with 3 cr2s, sorry its filedropper, I can't find any way to upload a file to this forum at all -

                        http://www.filedropper.com/ceilinglight

                        You can test the script for your self with these cr2s. Here's a zip file of the exposures converted manually -

                        http://www.filedropper.com/ceilinglightexposures

                        I also have a link for a zip file with 5 cr2s if you want to make a script with 5 raws -

                        http://www.filedropper.com/woodsfisheye

                        Also here is an excel table I made that has multiple conversions from 1, 3, and 5 cr2 brackets -

                        http://www.filedropper.com/rawbracketingcharts

                         

                        The chart shows the EV range of bracketed cr2s and the conversions you can get from them.  It assumes you can get +-4 EVs from each cr2.  Although there is information you can get from 1 cr2 from -4 EV to +4 EV, its not recommended that you use exposures from the whole range from a middle exposure, because the results can cause high noise and contrast. The only times when you use an exposure from -4 is if the cr2 file was already underexposed or you use +4 from a cr2 that was overexposed. That's why I choose to use -4 and -2 from the E01 cr2 and +2 and +4 from the E03 file, and why I inly used the range of -2 to +2 from the E02 cr2.

                         

                        I've also noticed that the script saves the jpegs without any exif camera data. Opening the cr2s manually in camera raw with photoshop, the exif seems to stay with the file. I'm normally not picky about the metadata, but I believe you need the correct shutter speeds embeded in order to here Merge to HDR work properly.

                         

                        Although, even if you could keep the camera info, you would still need to change the shutter speeds to the correct ones, because the shutter speed would be the same as the cr2 file's speed. I think it would make this script perfect if you could adjust the shutter speeds to the correct ones.

                         

                        For example, with the Ceiling_Light images I shot, converting the Ceiling_Light files manually without correcting the exif, the shutter speeds  would end up being -

                         

                        Ceiling_Light_E01.cr2 Shutter Speed -> Ceiling_Light_E01.jpg Shutter Speed = 1/2000 sec.

                        Ceiling_Light_E01.cr2 Shutter Speed -> Ceiling_Light_E02.jpg Shutter Speed = 1/2000 sec.

                        Ceiling_Light_E02.cr2 Shutter Speed -> Ceiling_Light_E03.jpg Shutter Speed = 1/500 sec.

                        Ceiling_Light_E02.cr2 Shutter Speed -> Ceiling_Light_E04.jpg Shutter Speed = 1/500 sec.

                        Ceiling_Light_E02.cr2 Shutter Speed -> Ceiling_Light_E05.jpg Shutter Speed = 1/500 sec.

                        Ceiling_Light_E03.cr2 Shutter Speed -> Ceiling_Light_E06.jpg Shutter Speed = 1/125 sec.

                        Ceiling_Light_E03.cr2 Shutter Speed -> Ceiling_Light_E07.jpg Shutter Speed = 1/125 sec.

                         

                        Since the converted exposures should be seperated by 2 EV each, the resulting speed should be 4x the last, so I would reference the Ceiling_Light_E02.cr2's speed which would be 1/500 sec. -

                         

                        Ceiling_Light_E01.cr2 Shutter Speed -> Ceiling_Light_E01.jpg Shutter Speed = 1/32000 sec. = 1/64x

                        Ceiling_Light_E01.cr2 Shutter Speed -> Ceiling_Light_E02.jpg Shutter Speed = 1/8000 sec. = 1/16x

                        Ceiling_Light_E02.cr2 Shutter Speed -> Ceiling_Light_E03.jpg Shutter Speed = 1/2000 sec. = 1/4x

                        Ceiling_Light_E02.cr2 Shutter Speed -> Ceiling_Light_E04.jpg Shutter Speed = 1/500 sec.

                        Ceiling_Light_E02.cr2 Shutter Speed -> Ceiling_Light_E05.jpg Shutter Speed = 1/125 sec. = 4x

                        Ceiling_Light_E03.cr2 Shutter Speed -> Ceiling_Light_E06.jpg Shutter Speed = 1/30 sec. = 16x

                        Ceiling_Light_E03.cr2 Shutter Speed -> Ceiling_Light_E07.jpg Shutter Speed = 1/8 sec. = 64x

                         

                        However, I'm not even sure sure if this is possible, because for, me I can't manually edit the camera exif section in bridge, and I have to use a seperate metadata editor.

                        • 9. Re: Batch process RAW exposures, please help!
                          Paul Riggott Level 6

                          I wonder if you could try this now as it should add the exif shutter speed and camera raw ev to each JPG.

                           

                           

                          #target bridge   
                             if( BridgeTalk.appName == "bridge" ) {  
                          CR2JPG = MenuElement.create("command", "CR2 to Seven JPGs", "at the end of Tools");
                          }
                          CR2JPG.onSelect = function () { 
                          var progressBar = function(title) {
                          var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
                          pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
                          st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
                          st.justify = 'center';
                          w.center();
                          this.reset = function( msg,maxValue ) {
                          st.text = msg;
                          pb.value = 0;
                          pb.maxvalue = maxValue||0;
                          pb.visible = !!maxValue;
                          w.show();
                          };
                          this.hit = function() { ++pb.value; };
                          this.hide = function() { w.hide(); };
                          this.close = function() { w.close(); };
                          this.show = function() { w.show(); };
                          this.update = function() { w.update(); };
                          this.layout = function() { w.layout.layout(); };
                          };
                          function doPbar(){
                          pBar.hit();
                          pBar.hide();
                          pBar.show();
                              }
                          var count = 0;
                          var Path = Folder(app.document.presentationPath);
                          var group1 = Path.getFiles(/\e01.cr2$/i);
                          var group2 = Path.getFiles(/\e02.cr2$/i);
                          var group3 = Path.getFiles(/\e03.cr2$/i);
                          count += group1.length;
                          count += group2.length;
                          count += group3.length;
                          var jpgFolder = Folder(Path+"/JPG");
                          if(!jpgFolder.exists) jpgFolder.create();
                          if(count <1) return;
                          var pBar = new progressBar("CR2 to Seven JPGs");
                          pBar.reset("Processing E01 Files", (group1.length*2));
                          for(var a in group1){
                          var thumb = new Thumbnail(group1[a]);
                          var Name = decodeURI(group1[a].name).replace(/\.[^\.]+$/, '');
                          Name = Name.replace(/e01$/i,'');
                          group1Exposure = setEV(group1[a],-4);
                          var BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E01.jpg" );
                          BM.exportTo( exportFile,  100);
                          doPbar();
                          putXMPData(exportFile,"1/32000",-4);
                          setEV(group1[a],-2);
                          BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E02.jpg" );
                          BM.exportTo( exportFile,  100);
                          setEV(group1[a],group1Exposure);
                          doPbar();
                          putXMPData(exportFile,"1/8000",-2);
                              }
                          pBar.reset("Processing E02 Files", (group2.length*3));
                          for(var b in group2){
                          var thumb = new Thumbnail(group2[b]);
                          var Name = decodeURI(group2[b].name).replace(/\.[^\.]+$/, '');
                          Name = Name.replace(/e02$/i,'');
                          group2Exposure = setEV(group2[b],-2);
                          var BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E03.jpg" );
                          BM.exportTo( exportFile,  100);
                          doPbar();
                          putXMPData(exportFile,"1/2000",-2);
                          setEV(group2[b],0);
                          BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E04.jpg" );
                          BM.exportTo( exportFile,  100);
                          doPbar();
                          putXMPData(exportFile,"1/500",0);
                          setEV(group2[b],2);
                          BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E05.jpg" );
                          BM.exportTo( exportFile,  100);
                          setEV(group2[b],group2Exposure);
                          doPbar();
                          putXMPData(exportFile,"1/125",2);
                              }
                          pBar.reset("Processing E03 Files", (group3.length*2));
                          for(var c in group3){
                          var thumb = new Thumbnail(group3[c]);
                          var Name = decodeURI(group3[c].name).replace(/\.[^\.]+$/, '');
                          Name = Name.replace(/e03$/i,'');
                          group2Exposure = setEV(group3[c],2);
                          var BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E06.jpg" );
                          BM.exportTo( exportFile,  100);
                          doPbar();
                          putXMPData(exportFile,"1/30",2);
                          setEV(group3[c],4);
                          BM = createBM(thumb);
                          var exportFile = new File( jpgFolder + "/" + Name + "E07.jpg" );
                          BM.exportTo( exportFile,  100);
                          setEV(group3[c],group2Exposure);
                          doPbar();
                          putXMPData(exportFile,"1/8",4);
                              }
                          pBar.close();
                          function setEV(thumb,evValue){
                          var Name = decodeURI(new Thumbnail(thumb).spec.name).replace(/\.[^\.]+$/, '');
                          var file = new File(new Thumbnail(thumb).spec.path +"/" +Name +".xmp");
                          try{
                          if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
                            if(file.exists){
                               file.open('r');
                               file.encoding = "UTF8";
                               file.lineFeed = "unix"; 
                               file.open("r", "TEXT", "????");
                               var xmpStr = file.read();
                               file.close();
                               }else{
                                   var xmpStr='';
                                   }
                               var xmp = new XMPMeta( xmpStr );
                              var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                              xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                              xmp.setProperty(XMPConst.NS_CAMERA_RAW, "Exposure",Number(evValue)); 
                               file.open('w');
                               file.encoding = "UTF8";
                               file.lineFeed = "unix"; 
                               file.write( xmp.serialize() );
                               file.close();
                               if(exposureValue  == undefined) exposureValue = 0;
                               }catch(e){alert(e+"-"+e.line);}
                               return exposureValue;
                          };
                          function createBM(thumb){
                          var sourceBitmap = undefined;
                          app.synchronousMode = true;
                          sourceBitmap = thumb.core.fullsize.fullsize; 
                          app.synchronousMode = false; 
                          sourceBitmap = sourceBitmap.rotate(thumb.rotation);
                          return sourceBitmap;
                              }
                          };
                          function putXMPData(fileName,exposureTime,evValue){
                          if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
                          var xmpf = new XMPFile(fileName.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE | XMPConst.OPEN_USE_SMART_HANDLER );
                          var xmp = xmpf.getXMP();
                           try{
                          xmp.setProperty(XMPConst.NS_TIFF, 'Make', 'Canon');
                          xmp.setProperty(XMPConst.NS_TIFF, 'Model', 'Canon EOS REBEL T1i');
                          xmp.setProperty(XMPConst.NS_EXIF, 'ExposureTime', exposureTime);
                          xmp.setProperty(XMPConst.NS_EXIF, 'FNumber', '63/10');
                          xmp.setProperty(XMPConst.NS_CAMERA_RAW, 'Exposure',Number(evValue)); 
                          if (xmpf.canPutXMP(xmp)) {
                                  xmpf.putXMP(xmp);
                                  }else{
                                      alert(e.message); 
                                  }
                                  xmpf.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
                          }catch(e){}
                          }
                          
                          
                          • 10. Re: Batch process RAW exposures, please help!
                            Ian___ Level 1

                            Hey thanks for all of your help Paul. The Shutter speed info seems to be perfect. I'm not sure why though, the correct exposures aren't being saved. Have you tried those files I posted, to see for your self?

                            • 11. Re: Batch process RAW exposures, please help!
                              Paul Riggott Level 6

                              I wonder what setting you have for thumbnails in Bridge?

                              This is how mine are set up...

                              Quality.jpg

                              • 12. Re: Batch process RAW exposures, please help!
                                Ian___ Level 1

                                Hi Paul, I'm using the same setting that's in your picture, Always High Quality. I'm using Bridge CS5 4.0.5.11 if that helps.I also have Extendscript Toolkit CS5 as well as CS4 since I had to install the Premiere and After Effects CS4 32 bit support package if that helps also.

                                • 13. Re: Batch process RAW exposures, please help!
                                  Paul Riggott Level 6

                                  Ok, now for something completley different! We will try a Photoshop script and see how that does?

                                  NB: this assumes that there is no xmp files associated with the cr2 files.

                                   

                                  #target Photoshop
                                  app.bringToFront();
                                  main();
                                  function main(){
                                  var Path  = Folder.selectDialog("Please select top level input folder");
                                  var progressBar = function(title) {
                                  var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
                                  pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
                                  st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
                                  st.justify = 'center';
                                  w.center();
                                  this.reset = function( msg,maxValue ) {
                                  st.text = msg;
                                  pb.value = 0;
                                  pb.maxvalue = maxValue||0;
                                  pb.visible = !!maxValue;
                                  w.show();
                                  };
                                  this.hit = function() { ++pb.value; };
                                  this.hide = function() { w.hide(); };
                                  this.close = function() { w.close(); };
                                  this.show = function() { w.show(); };
                                  this.update = function() { w.update(); };
                                  this.layout = function() { w.layout.layout(); };
                                  };
                                  function doPbar(){
                                  pBar.hit();
                                  pBar.hide();
                                  pBar.show();
                                      }
                                  var count = 0;
                                  var group1 = Path.getFiles(/\e01.cr2$/i);
                                  var group2 = Path.getFiles(/\e02.cr2$/i);
                                  var group3 = Path.getFiles(/\e03.cr2$/i);
                                  count += group1.length;
                                  count += group2.length;
                                  count += group3.length;
                                  var jpgFolder = Folder(Path+"/JPG");
                                  if(!jpgFolder.exists) jpgFolder.create();
                                  if(count <1) return;
                                  var pBar = new progressBar("CR2 to Seven JPGs");
                                  pBar.reset("Processing E01 Files", (group1.length*2));
                                  for(var a in group1){
                                  open(group1[a]);
                                  var Name = decodeURI(group1[a].name).replace(/\.[^\.]+$/, '');
                                  Name = Name.replace(/e01$/i,'');
                                  takeSnapshot();
                                  exposureSetting(-4);
                                  var exportFile = new File( jpgFolder + "/" + Name + "E01.jpg" );
                                  saveJPEG(exportFile,12);
                                  revertToLastSnapshot();
                                  doPbar();
                                  exposureSetting(-2);
                                  var exportFile = new File( jpgFolder + "/" + Name + "E02.jpg" );
                                  saveJPEG(exportFile,12);
                                  app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                  doPbar();
                                      }
                                  pBar.reset("Processing E02 Files", (group2.length*3));
                                  for(var b in group2){
                                  open(group2[b]);
                                  var Name = decodeURI(group2[b].name).replace(/\.[^\.]+$/, '');
                                  Name = Name.replace(/e02$/i,'');
                                  takeSnapshot();
                                  exposureSetting(-2);
                                  var exportFile = new File( jpgFolder + "/" + Name + "E03.jpg" );
                                  saveJPEG(exportFile,12);
                                  revertToLastSnapshot();
                                  doPbar();
                                  var exportFile = new File( jpgFolder + "/" + Name + "E04.jpg" );//0 ev
                                  saveJPEG(exportFile,12);
                                  doPbar();
                                  exposureSetting(2);
                                  var exportFile = new File( jpgFolder + "/" + Name + "E05.jpg" );
                                  saveJPEG(exportFile,12);
                                  app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                  doPbar();
                                      }
                                  pBar.reset("Processing E03 Files", (group3.length*2));
                                  for(var c in group3){
                                  open(group3[c]);
                                  var Name = decodeURI(group3[c].name).replace(/\.[^\.]+$/, '');
                                  Name = Name.replace(/e03$/i,'');
                                  takeSnapshot();
                                  exposureSetting(2);
                                  var exportFile = new File( jpgFolder + "/" + Name + "E06.jpg" );
                                  saveJPEG(exportFile,12);
                                  revertToLastSnapshot();
                                  doPbar();
                                  exposureSetting(4);
                                  var exportFile = new File( jpgFolder + "/" + Name + "E07.jpg" );
                                  saveJPEG(exportFile,12);
                                  doPbar();
                                  app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                      }
                                  pBar.close();
                                  }
                                  function exposureSetting(exposure) {
                                  var desc = new ActionDescriptor();
                                  desc.putEnumerated( stringIDToTypeID('presetKind'), stringIDToTypeID('presetKindType'), stringIDToTypeID('presetKindCustom') );
                                  desc.putDouble( charIDToTypeID('Exps'), exposure );
                                  desc.putDouble( charIDToTypeID('Ofst'), 0.000000 );
                                  desc.putDouble( stringIDToTypeID('gammaCorrection'), 1.000000 );
                                  executeAction( charIDToTypeID('Exps'), desc, DialogModes.NO );
                                  };
                                  function takeSnapshot() { 
                                     var desc = new ActionDescriptor(); 
                                     var sref = new ActionReference();  
                                     sref.putClass(charIDToTypeID("SnpS")); 
                                     desc.putReference(charIDToTypeID("null"), sref); 
                                     var fref = new ActionReference();  
                                     fref.putProperty(charIDToTypeID("HstS"), charIDToTypeID("CrnH")); 
                                     desc.putReference(charIDToTypeID("From"), fref ); 
                                     executeAction(charIDToTypeID("Mk  "), desc, DialogModes.NO ); 
                                  } 
                                  function revertToLastSnapshot(){ 
                                      var desc2 = new ActionDescriptor();
                                          var ref1 = new ActionReference();
                                          ref1.putName( charIDToTypeID('SnpS'), "Snapshot 1" );
                                      desc2.putReference( charIDToTypeID('null'), ref1 );
                                      executeAction( charIDToTypeID('slct'), desc2, DialogModes.NO );
                                  };
                                  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);
                                  }
                                  
                                  
                                  
                                  • 14. Re: Batch process RAW exposures, please help!
                                    Ian___ Level 1

                                    Hey, Paul thanks again for your help. I will have to try this.  Although it would be really nice to have this in Photoshop I really would need to have existing settings in the xmp files, not for the exposure, but for white balance and lens corrections, since I mainly use hdr for panoramas.  Does this script delete the xmp files, or does it erase existing settings?  Looking through your code, its hard to tell if it does either.  If its possible to keep the xmp file, but overwrite the exposure setting, that would be great. Also does this save the correct exposure time in exif?

                                     

                                    Also, I decided to have a go at an attempt at batch hdr merging. All of the testing of it so far seems to be positive. It merges exposures located in specific directories name E01, E02, E03. It merges multiple bracket sets of up to 19 exposures in each set. You don't really need much more than 15 depending on your EV spacing, to get an accurate hdr.  The only thing that is stopping it from being perfect, is that I can't get the merged files to save in .hdr format, I can only get it to save as 32 bit psd, since, I guess that's the default file type.  I tried looking in the javascript reference, and I can't seem to find the correct saveOptions to save as radiance hdr. Maybe I'm saveing them wrong. Although I could probably just as easily convert them with an action.  Anyways let me know what you think, I figure these two scripts would go perfect together in Photoshop.

                                     

                                    Merge To HDR Batch.jsx -

                                     

                                    /*****************************************************************************

                                    * Author:       Ian Adams

                                    * Year:            2011

                                    * Version:        1.0

                                    * File:         Merge To HDR Batch.jsx

                                    * Application:  Photoshop

                                    * Description:  Batch merges exposure bracket sets to hdr from a local directory,

                                    * with up to 19 exposures each. Exposures should end with a suffix of _E01, _E02,

                                    * and so on. Exposures sets will be alphabetically merged, so make sure name

                                    * suffixes are consistant throughout each folder! Exposure folders should be

                                    * located in - "C:/Batch Processing/Bracketing/Exposure Bracketing/LDR" and should

                                    * be named E01, E02, E03....E19. As well as a folder named "HDR" under

                                    * "Exposure Bracketing", where the merged 32 bit files will be saved.

                                    *******************************************************************************/

                                     

                                    var runMergeToHDRFromScript = true;// define and set to true before including Merge To HDR.jsx

                                    var g_ScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");

                                    var g_ScriptPath = File( g_ScriptFolderPath+'/Merge To HDR.jsx' );

                                    $.evalFile( g_ScriptPath );

                                    mergeToHDR.deghostSetting = true

                                    mergeToHDR.useAlignment = true;

                                    mergeToHDR.outputBitDepth = 32;

                                    var OutputFolder = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/HDR");

                                    var IP_01 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E01");

                                    var IP_02 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E02");

                                    var IP_03 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E03");

                                    var IP_04 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E04");

                                    var IP_05 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E05");

                                    var IP_06 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E06");

                                    var IP_07 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E07");

                                    var IP_08 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E08");

                                    var IP_09 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E09");

                                    var IP_10 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E10");

                                    var IP_11 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E11");

                                    var IP_12 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E12");

                                    var IP_13 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E13");

                                    var IP_14 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E14");

                                    var IP_15 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E15");

                                    var IP_16 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E16");

                                    var IP_17 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E17");

                                    var IP_18 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E18");

                                    var IP_19 = Folder("C:/Batch Processing/Bracketing/Exposure Bracketing/LDR/E19");

                                    var IF_01 = IP_01.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_02 = IP_02.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_03 = IP_03.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_04 = IP_04.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_05 = IP_05.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_06 = IP_06.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_07 = IP_07.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_08 = IP_08.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_09 = IP_09.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_10 = IP_10.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_11 = IP_11.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_12 = IP_12.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_13 = IP_13.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_14 = IP_14.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_15 = IP_15.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_16 = IP_16.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_17 = IP_17.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_18 = IP_18.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var IF_19 = IP_19.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|t ga|mos|pef|png)$/i);

                                    var i_F;

                                    if (IF_01.length > 0) i_F = IF_01.length - 1;

                                     

                                    function MergeHDR19EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)],IF_14[(Num-1)],IF_15[(Num-1)],IF_16[(Num-1)],IF_17[(Num-1)],IF_18[(Num-1) ],IF_19[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR18EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)],IF_14[(Num-1)],IF_15[(Num-1)],IF_16[(Num-1)],IF_17[(Num-1)],IF_18[(Num-1) ]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR17EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)],IF_14[(Num-1)],IF_15[(Num-1)],IF_16[(Num-1)],IF_17[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR16EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)],IF_14[(Num-1)],IF_15[(Num-1)],IF_16[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR15EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)],IF_14[(Num-1)],IF_15[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR14EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)],IF_14[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR13EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ],IF_13[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR12EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)],IF_12[(Num-1) ]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR11EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)],IF_11[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR10EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)],IF_10[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR9EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)],IF_09[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR8EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)],IF_08[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR7EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ],IF_07[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR6EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)],IF_06[(Num-1) ]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR5EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)],IF_05[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR4EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)],IF_04[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                    function MergeHDR3EV(Num) {

                                      var AD;

                                      var saveFile;

                                      var FileArray;

                                      if (IF_01.length > (Num-1)) {

                                        var Name = decodeURI(IF_01[(Num-1)].name).replace(/\.[^\.]+$/, '');

                                        Name = Name.replace(/(_e01| e01)$/i,'');

                                        FileArray = [IF_01[(Num-1)],IF_02[(Num-1)],IF_03[(Num-1)]];

                                        mergeToHDR.mergeFilesToHDR( FileArray, true, -2 );

                                        AD = activeDocument;

                                        saveFile = File( OutputFolder + "/" + Name + ".hdr" );

                                        AD.saveAs(saveFile);

                                        AD.close();

                                      }                                

                                    }

                                     

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined && IF_14[0] != undefined && IF_15[0] != undefined && IF_16[0] != undefined && IF_17[0] != undefined && IF_18[0] != undefined && IF_19[0] != undefined) {

                                      for (var n = 1; n < 4; n++) {

                                        MergeHDR19EV(n);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined && IF_14[0] != undefined && IF_15[0] != undefined && IF_16[0] != undefined && IF_17[0] != undefined && IF_18[0] != undefined) {

                                      for (var n = 1; n < 4; n++) {

                                        MergeHDR18EV(n);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined && IF_14[0] != undefined && IF_15[0] != undefined && IF_16[0] != undefined && IF_17[0] != undefined) {

                                      for (var n17 = 1; n15 < 4; n17++) {

                                        MergeHDR17EV(n17);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined && IF_14[0] != undefined && IF_15[0] != undefined && IF_16[0] != undefined) {

                                      for (var n16 = 1; n16 < 4; n16++) {

                                        MergeHDR16EV(n16);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined && IF_14[0] != undefined && IF_15[0] != undefined) {

                                      for (var n15 = 1; n15 < 4; n15++) {

                                        MergeHDR15EV(n15);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined && IF_14[0] != undefined) {

                                      for (var n14 = 1; n < 4; n14++) {

                                        MergeHDR14EV(n14);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined && IF_13[0] != undefined) {

                                      for (var n13 = 1; n13 < 4; n13++) {

                                        MergeHDR13EV(n13);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined && IF_12[0] != undefined) {

                                      for (var n12 = 1; n12 < 4; n12++) {

                                        MergeHDR12EV(n12);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined && IF_11[0] != undefined) {

                                      for (var n11 = 1; n11 < 4; n11++) {

                                        MergeHDR11EV(n11);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined && IF_10[0] != undefined) {

                                      for (var n10 = 1; n10 < 4; n10++) {

                                        MergeHDR10EV(n10);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined && IF_09[0] != undefined) {

                                      for (var n9 = 1; n9 < 4; n9++) {

                                        MergeHDR9EV(n9);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined && IF_08[0] != undefined) {

                                      for (var n8 = 1; n8 < 4; n8++) {

                                        MergeHDR8EV(n8);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined && IF_07[0] != undefined) {

                                      for (var n7 = 1; n7 < 4; n7++) {

                                        MergeHDR7EV(n7);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined && IF_06[0] != undefined) {

                                      for (var n6 = 1; n6 < 4; n6++) {

                                        MergeHDR6EV(n6);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined && IF_05[0] != undefined) {

                                      for (var n5 = 1; n5 < 4; n5++) {

                                        MergeHDR5EV(n5);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined && IF_04[0] != undefined) {

                                      for (var n4 = 1; n4 < 4; n4++) {

                                        MergeHDR4EV(n4);

                                      }

                                    } else

                                    if (IF_01[0] != undefined && IF_02[0] != undefined && IF_03[0] != undefined) {

                                      for (var n3 = 1; n3 < 4; n3++) {

                                        MergeHDR3EV(n3);

                                      }

                                    }

                                    • 15. Re: Batch process RAW exposures, please help!
                                      Paul Riggott Level 6

                                      Hi, yes using xmp will be fine so long as it doesn't have the exposure set, if it has that will be taken as Zero.

                                       

                                      Couldn't make much sence out of the script you have posted and you can't save HDR like you have it there.

                                      You might like to try this that I've just put together, it will save 16bit as PSD and 32bit as HDR, you can select the group(s) of files to be processed.

                                      It doesn't matter how many files per group, it will sort that out.

                                       

                                       

                                      #target photoshop
                                      app.bringToFront();
                                      main()
                                      
                                      function main(){
                                      Prefs ={};
                                      try{
                                        var desc1 = app.getCustomOptions('0bafbed0-0bc7-11e1-be50-0800200c9a66');
                                        Prefs = eval(desc1.getString(0));
                                      }catch(e){
                                      Prefs.folder1 = Folder("~/desktop");
                                      Prefs.folder2 = Folder("~/desktop");
                                      Prefs.bits = false;
                                          }
                                      var win = new Window( 'dialog', 'HDR' ); 
                                      g = win.graphics;
                                      var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
                                      g.backgroundColor = myBrush;
                                      win.orientation='row';
                                      win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"}); 
                                      win.g1 = win.p1.add('group');
                                      win.g1.orientation = "row";
                                      win.title = win.g1.add('statictext',undefined,'HDR process');
                                      win.title.alignment="fill";
                                      var g = win.title.graphics;
                                      g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
                                      win.g5 =win.p1.add('group');
                                      win.g5.orientation = "row";
                                      win.g5.alignment='left';
                                      win.g5.spacing=10;
                                      win.g5.st1 = win.g5.add('statictext',undefined,'Please select folder of files to process');
                                      win.g10 =win.p1.add('group');
                                      win.g10.orientation = "row";
                                      win.g10.alignment='left';
                                      win.g10.spacing=10;
                                      win.g10.et1 = win.g10.add('edittext');
                                      win.g10.et1.preferredSize=[400,20];
                                      win.g10.et1.enabled = false;
                                      win.g10.bu1 = win.g10.add('button',undefined,'Browse');
                                      win.g10.bu1.onClick = function() {
                                        topLevelFolder = Folder.selectDialog("Please select the source folder",Prefs.folder1); 
                                       if(topLevelFolder !=null){
                                        win.g10.et1.text =  decodeURI(topLevelFolder.fsName); 
                                              processHDRList();
                                        }
                                      }
                                      win.g15 =win.p1.add('group');
                                      win.g15.orientation = "row";
                                      win.g15.alignment='left';
                                      win.g15.spacing=10;
                                      win.g15.st1 = win.g15.add('statictext',undefined,'Please select output folder');
                                      win.g20 =win.p1.add('group');
                                      win.g20.orientation = "row";
                                      win.g20.alignment='left';
                                      win.g20.spacing=10;
                                      win.g20.et1 = win.g20.add('edittext');
                                      win.g20.et1.preferredSize=[400,20];
                                      win.g20.et1.enabled = false;
                                      win.g20.bu1 = win.g20.add('button',undefined,'Browse');
                                      win.g30 =win.p1.add('group');
                                      win.g30.orientation = "row";
                                      win.g30.alignment='left';
                                      win.g30.spacing=10;
                                      win.g30.st1 = win.g30.add('statictext',undefined,'Please select HDR Group to process');
                                      win.g30.dd1 = win.g30.add('dropdownlist');
                                      win.g30.dd1.preferredSize=[200,20];
                                      win.g20.bu1.onClick = function() {
                                        outPutFolder = Folder.selectDialog("Please select the output folder",Prefs.folder2); 
                                       if(outPutFolder !=null){
                                        win.g20.et1.text =  decodeURI(outPutFolder.fsName); 
                                        }
                                      }
                                      win.g40 =win.p1.add('group');
                                      win.g40.orientation = "row";
                                      win.g40.alignment='left';
                                      win.g40.spacing=10;
                                      win.g40.cb1 = win.g40.add('checkbox',undefined,'Create all HDRs');
                                      win.g40.cb2 = win.g40.add('checkbox',undefined,'32 bit (default 16 bit)');
                                      win.g40.cb2.helpTip="16 bit will be saved as psd, 32 bit as an hdr file";
                                      win.g40.cb2.value = Prefs.bits;
                                      function processHDRList(){
                                      var fileList = topLevelFolder.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dc2|erf|raf|orf|tga|mos|pef|png)$/i);
                                      ddList=[];
                                      for(var s in fileList){
                                          ddList.push(decodeURI(fileList[s].name).replace(/_E\d+\....$/i,''));
                                          }
                                      ddList = ReturnUniqueSortedList(ddList);
                                      win.g30.dd1.removeAll();
                                      for(var z in ddList){
                                          win.g30.dd1.add('item', ddList[z].toString());
                                          }
                                      win.g30.dd1.selection=0;
                                      }
                                      win.g300 =win.p1.add('group');
                                      win.g300.orientation = "row";
                                      win.g300.alignment='center';
                                      win.g300.spacing=10;
                                      win.g300.bu1 = win.g300.add('button',undefined,'Process');
                                      win.g300.bu1.preferredSize=[240,30];
                                      win.g300.bu2 = win.g300.add('button',undefined,'Cancel');
                                      win.g300.bu2.preferredSize=[240,30];
                                      win.g300.bu1.onClick=function(){
                                      if(win.g10.et1.text == ''){
                                          alert("Source folder has not been selected!");
                                          return
                                          }
                                      if(win.g20.et1.text == ''){
                                          alert("Output folder has not been selected!");
                                          return
                                          }
                                      try{    
                                      if(ddList.length <1) {
                                          alert("No files to process!");
                                          return;
                                          }
                                      Prefs.folder1 = topLevelFolder;
                                      Prefs.folder2 = outPutFolder;
                                      Prefs.bits = win.g40.cb2.value;
                                      var desc2 = new ActionDescriptor();
                                      desc2.putString(0, Prefs.toSource()); 
                                      app.putCustomOptions('0bafbed0-0bc7-11e1-be50-0800200c9a66', desc2, true );
                                      win.close(0);
                                      if(!win.g40.cb1.value){
                                      var fileMask = win.g30.dd1.selection.text.toString() +"_E*.*";
                                      var Name = win.g30.dd1.selection.text.toString();
                                      var groupList = topLevelFolder.getFiles(fileMask);
                                      HDRMergeGroups(groupList,Name);
                                      }else{
                                          for(var t in ddList){
                                              var fileMask = ddList[t].toString() +"_E*.*";
                                              var groupList = topLevelFolder.getFiles(fileMask);
                                              var Name = ddList[t].toString();
                                              HDRMergeGroups(groupList,Name);
                                              }
                                          }
                                      }catch(e){alert(e + " - " +e.line);}
                                      }
                                      win.center();
                                      win.show();
                                      function ReturnUniqueSortedList(ArrayName){
                                      var unduped = new Object;
                                      for (var i = 0; i < ArrayName.length; i++) {   
                                      unduped[ArrayName[i]] = ArrayName[i];
                                      }
                                      var uniques = new Array;for (var k in unduped) {
                                         uniques.push(unduped[k]);
                                         }
                                      uniques.sort();
                                      return uniques;
                                      }
                                      function HDRMergeGroups(groupList,Name){
                                          try{
                                      var runMergeToHDRFromScript = true;
                                      var g_ScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
                                      var g_ScriptPath = File( g_ScriptFolderPath+'/Merge To HDR.jsx' );
                                      $.evalFile( g_ScriptPath );
                                      mergeToHDR.deghostSetting = true;
                                      mergeToHDR.useAlignment = true;
                                      if(win.g40.cb2.value){
                                      mergeToHDR.outputBitDepth= 32;
                                      mergeToHDR.mergeFilesToHDR( groupList, true, -2 );
                                      var saveFile = File(outPutFolder + "/" + Name + ".hdr");
                                      saveAsHDR(saveFile);
                                      }else{
                                          mergeToHDR.outputBitDepth= 16;
                                          mergeToHDR.mergeFilesToHDR( groupList, true, -2 );
                                          var saveFile = File(outPutFolder + "/" + Name + ".psd");
                                          savePSD(saveFile);
                                          }
                                      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                      }catch(e){alert(e + " - " + e.line);}
                                      }
                                      function savePSD(saveFile){ 
                                      psdSaveOptions = new PhotoshopSaveOptions(); 
                                      psdSaveOptions.embedColorProfile = true; 
                                      psdSaveOptions.alphaChannels = true;  
                                      psdSaveOptions.layers = true;  
                                      activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE); 
                                      }
                                      function saveAsHDR(saveFile) {
                                          var desc6 = new ActionDescriptor();
                                          desc6.putString(app.charIDToTypeID('As  '), """Radiance""" );
                                          desc6.putPath(app.charIDToTypeID('In  '), saveFile );
                                          executeAction( app.charIDToTypeID('save'), desc6, DialogModes.NO );
                                      }
                                      }
                                      
                                       
                                      • 16. Re: Batch process RAW exposures, please help!
                                        Ian___ Level 1

                                        Hmm, I was wondering how your script is converting the exposures from the cr2 files?  It looks like the exposures are just taken from the cr2 files and darkened or lightened for the lower and higher exposures. They don't seem to contain any new information, or dynamic range from the Camera Raw dialogue settings. Here's a rar file with a comparison of converting with your script, and with converting them manually -

                                         

                                        http://www.adrive.com/public/621616e2dbd233a75fb35400acba92f90a4965d6af8d9bc0e3f0a59148313 9e0.html

                                         

                                        Also your hdr script works great, and it has a great ui with it. How long did it take you to write that up? It took me a couple of days for my script.  The only thing with the script that I think needs to be changed is that you have to click ok on a dialogue stating that jpeg converted from raw loses dynamic range, and for doing hdr timelapse, it would be hard to have to keep clicking on that for each set. For some reason my script only asks for a confirmation once at the beginning.

                                         

                                        As far as how my script works, it searches for if there are files in the exposure directories, then gets arrays from each folder containing files, then gets the first file element from each array, merges them together, takes the name from the first folder - the _E01, and repeat for the next element.  I've fixed some inconsistencies in the script, and added dialogues for the user to choose input and output folders.  You still need to have the exposure folders in the input folder. But I think its good to have them, to be organized, and its nice to be able to see the different files with the same exposure.  I've also added the function to save as hdr in the output directory. Also I've added dos batch files to move files to and from the exposure folders. Here's a rar with the batch files and script -

                                         

                                        http://www.adrive.com/public/dc6892c75f99f80d1ad2c0bb5864a55e890c58c8a6bcd5ca6de00bc779f49 61f.html

                                        • 17. Re: Batch process RAW exposures, please help!
                                          Paul Riggott Level 6

                                          Thanks for the info ian, I was using Image - Ajustments - Exposure to make all the alterations, seems that this is not the way forward, I thought it might save a lot of time rather than going through ACR for each exposure. I will have another go at that.

                                          Its strange that you are getting prompts when running the HDR script and it goes through without a single prompt on my machine.

                                          Could you try adding this one line and see if it fixs it..

                                           

                                          app.displayDialogs = DialogModes.NO;
                                          

                                          The script took less than an hour to write and test.

                                           

                                          I will re-write the other script and get back to you.

                                          • 18. Re: Batch process RAW exposures, please help!
                                            Paul Riggott Level 6

                                            Yes it does make a big difference! Could you try this Photoshop script now....

                                             

                                             

                                            #target Photoshop
                                            app.bringToFront();
                                            main();
                                            function main(){
                                            var Path  = Folder.selectDialog("Please select top level input folder");
                                            var progressBar = function(title) {
                                            var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
                                            pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
                                            st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
                                            st.justify = 'center';
                                            w.center();
                                            this.reset = function( msg,maxValue ) {
                                            st.text = msg;
                                            pb.value = 0;
                                            pb.maxvalue = maxValue||0;
                                            pb.visible = !!maxValue;
                                            w.show();
                                            };
                                            this.hit = function() { ++pb.value; };
                                            this.hide = function() { w.hide(); };
                                            this.close = function() { w.close(); };
                                            this.show = function() { w.show(); };
                                            this.update = function() { w.update(); };
                                            this.layout = function() { w.layout.layout(); };
                                            };
                                            function doPbar(){
                                            pBar.hit();
                                            pBar.hide();
                                            pBar.show();
                                                }
                                            var count = 0;
                                            var group1 = Path.getFiles(/\e01.cr2$/i);
                                            var group2 = Path.getFiles(/\e02.cr2$/i);
                                            var group3 = Path.getFiles(/\e03.cr2$/i);
                                            count += group1.length;
                                            count += group2.length;
                                            count += group3.length;
                                            var jpgFolder = Folder(Path+"/JPG");
                                            if(!jpgFolder.exists) jpgFolder.create();
                                            if(count <1) return;
                                            var pBar = new progressBar("CR2 to Seven JPGs");
                                            pBar.reset("Processing E01 Files", (group1.length*2));
                                            for(var a in group1){
                                            setEV(group1[a],-4);
                                            open(group1[a]);
                                            var Name = decodeURI(group1[a].name).replace(/\.[^\.]+$/, '');
                                            Name = Name.replace(/e01$/i,'');
                                            var exportFile = new File( jpgFolder + "/" + Name + "E01.jpg" );
                                            saveJPEG(exportFile,12);
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                            doPbar();
                                            setEV(group1[a],-2);
                                            open(group1[a]);
                                            var exportFile = new File( jpgFolder + "/" + Name + "E02.jpg" );
                                            saveJPEG(exportFile,12);
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                            doPbar();
                                                }
                                            pBar.reset("Processing E02 Files", (group2.length*3));
                                            for(var b in group2){
                                            setEV(group2[b],-2);
                                            open(group2[b]);
                                            var Name = decodeURI(group2[b].name).replace(/\.[^\.]+$/, '');
                                            Name = Name.replace(/e02$/i,'');
                                            var exportFile = new File( jpgFolder + "/" + Name + "E03.jpg" );
                                            saveJPEG(exportFile,12);
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                            doPbar();
                                            setEV(group2[b],0);
                                            open(group2[b]);
                                            var exportFile = new File( jpgFolder + "/" + Name + "E04.jpg" );//0 ev
                                            saveJPEG(exportFile,12);
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                            doPbar();
                                            setEV(group2[b],2);
                                            open(group2[b]);
                                            var exportFile = new File( jpgFolder + "/" + Name + "E05.jpg" );
                                            saveJPEG(exportFile,12);
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                            doPbar();
                                                }
                                            pBar.reset("Processing E03 Files", (group3.length*2));
                                            for(var c in group3){
                                            setEV(group3[c],2);
                                            open(group3[c]);
                                            var Name = decodeURI(group3[c].name).replace(/\.[^\.]+$/, '');
                                            Name = Name.replace(/e03$/i,'');
                                            var exportFile = new File( jpgFolder + "/" + Name + "E06.jpg" );
                                            saveJPEG(exportFile,12);
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                            doPbar();
                                            setEV(group3[c],4);
                                            open(group3[c]);
                                            var exportFile = new File( jpgFolder + "/" + Name + "E07.jpg" );
                                            saveJPEG(exportFile,12);
                                            doPbar();
                                            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                }
                                            pBar.close();
                                            }
                                            function setEV(thumb,evValue){
                                            var Name = decodeURI(thumb.name).replace(/\.[^\.]+$/, '');
                                            var file = new File(thumb.path +"/" +Name +".xmp");
                                            try{
                                            if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
                                              if(file.exists){
                                                 file.open('r');
                                                 file.encoding = "UTF8";
                                                 file.lineFeed = "unix"; 
                                                 file.open("r", "TEXT", "????");
                                                 var xmpStr = file.read();
                                                 file.close();
                                                 }else{
                                                     var xmpStr='';
                                                     }
                                                 var xmp = new XMPMeta( xmpStr );
                                                var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                                                xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                                                xmp.setProperty(XMPConst.NS_CAMERA_RAW, "Exposure",Number(evValue)); 
                                                 file.open('w');
                                                 file.encoding = "UTF8";
                                                 file.lineFeed = "unix"; 
                                                 file.write( xmp.serialize() );
                                                 file.close();
                                                 if(exposureValue  == undefined) exposureValue = 0;
                                                 }catch(e){alert(e+"-"+e.line);}
                                                 return exposureValue;
                                            };
                                            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);
                                            }
                                            
                                            
                                            
                                            • 19. Re: Batch process RAW exposures, please help!
                                              Ian___ Level 1

                                              Well, it looks like your cr2 script works great.  The last thing that would make it perfect is somehow saving the exif info, like with the Bridge script.  The exif is important because merge to hdr uses the exposure time to compute the tone curve. You could use other software like Photomatix, where you you wouldn't need any exif, but then that would defeat the purpose of doing everything in Photoshop.  I would just use bridge to batch edit the exif, but I can't get Bridge to edit any of the info in the camera section of the exif. 

                                               

                                              Also, I'm still getting the raw warnings with the hdr script. I've checked my preferences in Photoshop, but couldn't find any setting for that.  I've also tried putting that displayDialogs line in the script, and it still gives a warning for each hdr set. Is there a specific place to put the line in? I've tried at the start, end, and in the HDRMergeGroups function.  Anyway, thanks again for your continued help and patience.

                                              • 20. Re: Batch process RAW exposures, please help!
                                                Paul Riggott Level 6

                                                Hi Ian, I have found where the warning is coming from, it is the CreateImageStack.jsx script in the

                                                C:\Program Files\Adobe\Adobe Photoshop CS5 (64 Bit)\Presets\Scripts\Stack Scripts Only

                                                folder.

                                                If you comment out this section there will be no alerts.

                                                 

                                                 

                                                 /*
                                                 if (this.mustBeUnmodifiedRaw && hasCamRawChanges(doc))
                                                 {
                                                  this.giveWarning( "rawmod", "$$$/AdobePlugin/Shared/Exposuremerge/CamRawChange=: Files converted from Camera Raw format may lose dynamic range.  For best results, merge the original Camera Raw files.", false );
                                                  this.exposureMetadataValid = false;
                                                 }
                                                    */
                                                
                                                

                                                 

                                                Please try this new code as it adds the new metadata...

                                                 

                                                 

                                                #target Photoshop
                                                app.bringToFront();
                                                main();
                                                function main(){
                                                app.displayDialogs = DialogModes.NO;
                                                var Path  = Folder.selectDialog("Please select top level input folder");
                                                var progressBar = function(title) {
                                                var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),
                                                pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),
                                                st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );
                                                st.justify = 'center';
                                                w.center();
                                                this.reset = function( msg,maxValue ) {
                                                st.text = msg;
                                                pb.value = 0;
                                                pb.maxvalue = maxValue||0;
                                                pb.visible = !!maxValue;
                                                w.show();
                                                };
                                                this.hit = function() { ++pb.value; };
                                                this.hide = function() { w.hide(); };
                                                this.close = function() { w.close(); };
                                                this.show = function() { w.show(); };
                                                this.update = function() { w.update(); };
                                                this.layout = function() { w.layout.layout(); };
                                                };
                                                function doPbar(){
                                                pBar.hit();
                                                pBar.hide();
                                                pBar.show();
                                                    }
                                                var count = 0;
                                                var group1 = Path.getFiles(/\e01.cr2$/i);
                                                var group2 = Path.getFiles(/\e02.cr2$/i);
                                                var group3 = Path.getFiles(/\e03.cr2$/i);
                                                count += group1.length;
                                                count += group2.length;
                                                count += group3.length;
                                                var jpgFolder = Folder(Path+"/JPG");
                                                if(!jpgFolder.exists) jpgFolder.create();
                                                if(count <1) return;
                                                var pBar = new progressBar("CR2 to Seven JPGs");
                                                pBar.reset("Processing E01 Files", (group1.length*2));
                                                for(var a in group1){
                                                setEV(group1[a],-4);
                                                open(group1[a]);
                                                var Name = decodeURI(group1[a].name).replace(/\.[^\.]+$/, '');
                                                Name = Name.replace(/e01$/i,'');
                                                var exportFile = new File( jpgFolder + "/" + Name + "E01.jpg" );
                                                SaveForWeb(exportFile,100);
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/32000",-4);
                                                doPbar();
                                                setEV(group1[a],-2);
                                                open(group1[a]);
                                                var exportFile = new File( jpgFolder + "/" + Name + "E02.jpg" );
                                                SaveForWeb(exportFile,100);
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/8000",-2);
                                                doPbar();
                                                    }
                                                pBar.reset("Processing E02 Files", (group2.length*3));
                                                for(var b in group2){
                                                setEV(group2[b],-2);
                                                open(group2[b]);
                                                var Name = decodeURI(group2[b].name).replace(/\.[^\.]+$/, '');
                                                Name = Name.replace(/e02$/i,'');
                                                var exportFile = new File( jpgFolder + "/" + Name + "E03.jpg" );
                                                SaveForWeb(exportFile,100);
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/2000",-2);
                                                doPbar();
                                                setEV(group2[b],0);
                                                open(group2[b]);
                                                var exportFile = new File( jpgFolder + "/" + Name + "E04.jpg" );//0 ev
                                                SaveForWeb(exportFile,100);
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/500",0);
                                                doPbar();
                                                setEV(group2[b],2);
                                                open(group2[b]);
                                                var exportFile = new File( jpgFolder + "/" + Name + "E05.jpg" );
                                                SaveForWeb(exportFile,100);
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/125",2);
                                                doPbar();
                                                    }
                                                pBar.reset("Processing E03 Files", (group3.length*2));
                                                for(var c in group3){
                                                setEV(group3[c],2);
                                                open(group3[c]);
                                                var Name = decodeURI(group3[c].name).replace(/\.[^\.]+$/, '');
                                                Name = Name.replace(/e03$/i,'');
                                                var exportFile = new File( jpgFolder + "/" + Name + "E06.jpg" );
                                                SaveForWeb(exportFile,100);
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/30",2);
                                                doPbar();
                                                setEV(group3[c],4);
                                                open(group3[c]);
                                                var exportFile = new File( jpgFolder + "/" + Name + "E07.jpg" );
                                                SaveForWeb(exportFile,100);
                                                doPbar();
                                                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                                                putXMPData(exportFile,"1/8",4);
                                                    }
                                                pBar.close();
                                                }
                                                function setEV(thumb,evValue){
                                                var Name = decodeURI(thumb.name).replace(/\.[^\.]+$/, '');
                                                var file = new File(thumb.path +"/" +Name +".xmp");
                                                try{
                                                if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
                                                  if(file.exists){
                                                     file.open('r');
                                                     file.encoding = "UTF8";
                                                     file.lineFeed = "unix"; 
                                                     file.open("r", "TEXT", "????");
                                                     var xmpStr = file.read();
                                                     file.close();
                                                     }else{
                                                         var xmpStr='';
                                                         }
                                                     var xmp = new XMPMeta( xmpStr );
                                                    var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                                                    xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure"); 
                                                    xmp.setProperty(XMPConst.NS_CAMERA_RAW, "Exposure",Number(evValue)); 
                                                     file.open('w');
                                                     file.encoding = "UTF8";
                                                     file.lineFeed = "unix"; 
                                                     file.write( xmp.serialize() );
                                                     file.close();
                                                     if(exposureValue  == undefined) exposureValue = 0;
                                                     }catch(e){alert(e+"-"+e.line);}
                                                     return exposureValue;
                                                };
                                                function putXMPData(fileName,exposureTime,evValue){
                                                if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
                                                var xmpf = new XMPFile(fileName.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE | XMPConst.OPEN_USE_SMART_HANDLER );
                                                var xmp = xmpf.getXMP();
                                                 try{
                                                xmp.setProperty(XMPConst.NS_TIFF, 'Make', 'Canon');
                                                xmp.setProperty(XMPConst.NS_TIFF, 'Model', 'Canon EOS REBEL T1i');
                                                xmp.setProperty(XMPConst.NS_EXIF, 'ExposureTime', exposureTime);
                                                xmp.setProperty(XMPConst.NS_EXIF, 'FNumber', '63/10');
                                                xmp.setProperty(XMPConst.NS_CAMERA_RAW, 'Exposure',Number(evValue)); 
                                                if (xmpf.canPutXMP(xmp)) {
                                                        xmpf.putXMP(xmp);
                                                        }else{
                                                            alert(e.message); 
                                                        }
                                                        xmpf.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
                                                }catch(e){}
                                                }
                                                function SaveForWeb(saveFile,jpegQuality) {
                                                var sfwOptions = new ExportOptionsSaveForWeb(); 
                                                   sfwOptions.format = SaveDocumentType.JPEG; 
                                                   sfwOptions.includeProfile = false; 
                                                   sfwOptions.interlaced = 0; 
                                                   sfwOptions.optimized = true; 
                                                   sfwOptions.quality = jpegQuality; 
                                                activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
                                                }
                                                
                                                
                                                • 21. Re: Batch process RAW exposures, please help!
                                                  Ian___ Level 1

                                                  Awesome, I believe everything works great now. Commenting that section worked great for the hdr warnings, thanks a lot man.

                                                   

                                                  The exif works, but I've noticed that you put explicit values for the exposure times. Is there a way of reading the cr2's exposure time as a decimal value from the middle exposure, and multiplying the next exposures by 4, 16, 64 and dividing the lower exposures by the same values? I think this would help a ton, as the exposure speeds would be different depending on the exposure speeds that were bracketed when you took the photos.  The only alternate to this, that I can think of is if you set up a ui where you select from a drop down menu, the shutter speed of the middle exposure, and the other speeds are derived from that.

                                                   

                                                  For example, here are the default shutter speeds you can choose from my camera -

                                                  1/4000,1/3000,1/2000,1/1500,1/1000,1/750,1/500,1/350,1/250,1/180,1/125,1/90,1/60,1/45,1/30 ,1/20,1/15,1/10,1/8,1/6,1/4,0.3,0.5,0.7,1,1.5,2,3,4,6,8,10,15,20,30

                                                  Say if we choose a middle speed of 1/60, the resulting 7 exposures would be 1/4000,1/1000,1/250,1/60,1/15,1/4,0. But if we choose the low end of 1/4000, the exposures should end up being 1/256000,1/64000,1/16000,1/4000,1/1000,1/250,1/60.  I'm guessing that the default shutter speeds were rounded off, to keep a simplified pattern of division, so you could probably change 1/256000,1/64000,1/16000 to 1/250000,1/60000,1/15000 to keep with this pattern.  If you add a ui I would also add in the same input and output directory options from the hdr script as well.

                                                  • 22. Re: Batch process RAW exposures, please help!
                                                    Ian___ Level 1

                                                    Man, thanks again, for your help. I have so many ideas for these scripts, but hardly any programming experience to fully write them.  Another idea I had was to make a script called "RAW to JPG Converter" with a drop down menu for various conversions for the EV spacing.  For example, I named your script "RAW 3x2EV To JPG 7x2EV", which means 3 raws, separated by 2 EV to 7 jpegs, separated by 2 EV. I've modified your script to make a version that's called "RAW 5x2EV To JPG 9x2EV", which is 5 raws, separated by 2 EV to 9 jpegs, separated by 2 EV.  It actually works just as good as the original, and since its from 5 raws, it has a very wide dynamic range. I just have to add the exif.  The conversions from the bracketing chart I posted earlier which I plan on modifying are -

                                                     

                                                    Straight Conversion

                                                    1 RAW to 9 Exposures x 1 EV (9 EV Range)               

                                                    1 RAW to 7 Exposures x 1 EV (7 EV Range)               

                                                    1 RAW to 5 Exposures x 2 EV (9 EV Range)                                       

                                                    1 RAW to 5 Exposures x 1 EV (5 EV Range)                               

                                                    1 RAW to 3 Exposures x 4 EV (9 EV Range)                               

                                                    1 RAW to 3 Exposures x 3 EV (7 EV Range)                               

                                                    1 RAW to 3 Exposures x 2 EV (5 EV Range)                               

                                                    1 RAW to 3 Exposures x 1 EV (3 EV Range)                               

                                                    3 RAWs x 1 EV to 11 Exposures x 1 EV (11 EV Range)

                                                    3 RAWs x 1 EV to 6 Exposures x 2 EV (11 EV Range)

                                                    3 RAWs x 1 EV to 3 Exposures x 5 EV (11 EV Range)

                                                    3 RAWs x 2 EV to 13 Exposures x 1 EV (13 EV Range)

                                                    3 RAWs x 2 EV to 7 Exposures x 2 EV (13 EV Range)

                                                    3 RAWs x 2 EV to 5 Exposures x 3 EV (13 EV Range)

                                                    3 RAWs x 2 EV to 4 Exposures x 4 EV (13 EV Range)

                                                    3 RAWs x 2 EV to 3 Exposures x 6 EV (13 EV Range)

                                                    3 RAWs x 3 EV to 15 Exposures x 1 EV (15 EV Range)

                                                    3 RAWs x 3 EV to 8 Exposures x 2 EV (15 EV Range)   

                                                    3 RAWs x 3 EV to 3 Exposures x 7 EV (15 EV Range)   

                                                    3 RAWs x 4 EV to 17 Exposures x 1 EV (17 EV Range)

                                                    3 RAWs x 4 EV to 9 Exposures x 2 EV (17 EV Range)   

                                                    3 RAWs x 4 EV to 5 Exposures x 4 EV (17 EV Range)

                                                    3 RAWs x 4 EV to 3 Exposures x 8 EV (17 EV Range)

                                                    5 RAWs x 1 EV to 13 Exposures x 1 EV (13 EV Range)

                                                    5 RAWs x 1 EV to 7 Exposures x 2 EV (13 EV Range)   

                                                    5 RAWs x 1 EV to 5 Exposures x 3 EV (13 EV Range)                                       

                                                    5 RAWs x 1 EV to 3 Exposures x 6 EV (13 EV Range)                                       

                                                    5 RAWs x 2 EV to 17 Exposures x 1 EV (17 EV Range)                                       

                                                    5 RAWs x 2 EV to 9 Exposures x 2 EV (17 EV Range)                                       

                                                    5 RAWs x 2 EV to 5 Exposures x 4 EV (17 EV Range)                                       

                                                    5 RAWs x 2 EV to 3 Exposures x 8 EV (17 EV Range)                                       

                                                    5 RAWs x 3 EV to 21 Exposures x 1 EV (21 EV Range)                                       

                                                    5 RAWs x 3 EV to 11 Exposures x 2 EV (21 EV Range)                                       

                                                    5 RAWs x 3 EV to 6 Exposures x 4 EV (21 EV Range)                                       

                                                    5 RAWs x 3 EV to 5 Exposures x 5 EV (21 EV Range)                                       

                                                    5 RAWs x 3 EV to 3 Exposures x 10 EV (21 EV Range)                                       

                                                    5 RAWs x 4 EV to 25 Exposures x 1 EV (25 EV Range)                                       

                                                    5 RAWs x 4 EV to 13 Exposures x 2 EV (25 EV Range)                                       

                                                    5 RAWs x 4 EV to 9 Exposures x 3 EV (25 EV Range)                                   

                                                    5 RAWs x 4 EV to 7 Exposures x 4 EV (25 EV Range)                                   

                                                    5 RAWs x 4 EV to 5 Exposures x 6 EV (25 EV Range)                               

                                                    5 RAWs x 4 EV to 3 Exposures x 12 EV (25 EV Range)      

                                                     

                                                    Although, if you add this option, and exif you would have to correlate with that conversion. For example, each shutter speed is seperated by 0.5 EV, so every other speed is seperated by 1 EV, and is 2x slower than the last, i.e. 1/500,1/350,1/250 - 1/250 is 2x slower than 1/500.  With 1/1000,1/750,1/500,1/350,1/250 - 1/250 is 4x slower than 1/1000 and is seperated by 2 EV.

                                                    • 23. Re: Batch process RAW exposures, please help!
                                                      Ian___ Level 1

                                                      Hey Paul, I think I finally have a way of returning the corresponding exposure speeds from a middle exposure time. Which is by using a function to multiply fractions. -

                                                       

                                                      function ExifEV(Input,Multiplier) {

                                                          var EVval = Math.abs(eval(Input)*eval(Multiplier)); // Positive Decimal

                                                          var EVvalN = 1; // Numerator

                                                          var EVvalD = 1; // Denominator

                                                          if (EVval < 0.5) EVvalD = Math.floor(1/EVval); else // For values less than 1/2

                                                          // For values greater than 1/2 or values less than 1-1/2, returns 1000ths

                                                          if (EVval < 1 || EVval > 1) {

                                                              EVvalN = Math.floor(EVval*1000);

                                                              EVvalD = 1000;

                                                          } else                                   

                                                          if (EVval > 1.5) EVvalN = Math.floor(EVval); // For values greater than 1-1/2

                                                          return String(EVvalN + "/" + EVvalD); // Return fraction

                                                      }

                                                      I've tested it using Extendscript and it seems to work fine.  Using the function with an input value of 1/2000 -

                                                       

                                                      ExifEV("1/2000","1/64");     // result = 1/128000 = 1/64x = -6EV

                                                      ExifEV("1/2000","1/16");     // result = 1/32000 = 1/16x = -4EV

                                                      ExifEV("1/2000","1/4");       // result = 1/8000 = 1/4x = -2EV

                                                      ExifEV("1/2000","1");          // result = 1/2000 = 1x = 0EV

                                                      ExifEV("1/2000","4");          // result = 1/500 = 4x = 2EV

                                                      ExifEV("1/2000","16");        // result = 1/125 = 16x = 4EV

                                                      ExifEV("1/2000","64");        // result = 1/31 = 64x = 6EV

                                                       

                                                      Using an edittext to enter the value of the middle exposure to plug into the the function is the best solution I have so far. The problem with this is that the different exposure sets would probably have a different middle exposure speed, so you would want to run the script for sets that have the same middle speed, to ensure that that resulting speeds where correct. For example, say you have 4 sets of 3 exposures. 2 sets have a center exposure time (the exposure time of the E02 files) of 1/2000th, one set has a middle time of 1/500, the other set has a time of 1/1000 -

                                                       

                                                      Set1_E01 - 1/500           Set2_E01 - 1/500          Set3_E01 - 1/125          Set4_E01 - 1/250

                                                      Set1_E02 - 1/2000         Set2_E02 - 1/2000        Set3_E02 - 1/500          Set4_E02 - 1/1000

                                                      Set1_E03 - 1/8000         Set2_E03 - 1/8000        Set3_E03 - 1/2000        Set4_E03 - 1/4000

                                                       

                                                      You would want to run the script for the first 2 sets with 1/2000, again for the third with 1/500, and again for the last set with 1/1000. The ideal solution would be to read the exposure time from the e02 files to calculate the values for the other files., this way you wouldn't need to enter anything.

                                                       

                                                      Is it possible to make a function to read the exposure time from a file?

                                                      • 24. Re: Batch process RAW exposures, please help!
                                                        Ian___ Level 1

                                                        I think I was able to make a function to get the exposure time from the raw's xmp file. So the xmp file has to already be saved with the exposure time in the exif section.

                                                         

                                                        function getEV(thumb){

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

                                                            var file = new File(thumb.path + "/" + Name + ".xmp");

                                                            try{

                                                                if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

                                                                if(file.exists){

                                                                    file.open('r');

                                                                    file.encoding = "UTF8";

                                                                    file.lineFeed = "unix";

                                                                    file.open("r", "TEXT", "????");

                                                                    var xmpStr = file.read();

                                                                    file.close();

                                                                }else{

                                                                    var xmpStr='';

                                                                }

                                                                var xmp = new XMPMeta( xmpStr );

                                                                var exposureTime = xmp.getProperty(XMPConst.NS_EXIF, 'ExposureTime');

                                                                if(exposureTime  == undefined) exposureTime = 1;

                                                            }catch(e){alert(e+"-"+e.line);}

                                                            return exposureTime;

                                                        };

                                                         

                                                        I was able to use the ui you put together from your hdr script, and used the functions from your cr2 script, to make the raw converter script. I've added a drop down list for the different conversion, and I added an option to either enter the exposure time for the middle exposure, or use the xmp's exposure time instead. So far I've only added a straight conversion method, where the files are converted, without any modifications, the 3 raw, and 5 raw conversion methods. Here's the script -

                                                         

                                                        #target photoshop

                                                        app.bringToFront();

                                                        main();

                                                        function main(){

                                                            Prefs = {};

                                                            try{

                                                                var desc1 = app.getCustomOptions('0bafbed0-0bc7-11e1-be50-0800200c9a66');

                                                                Prefs = eval(desc1.getString(0));

                                                            }catch(e){

                                                                Prefs.folder1 = Folder("~/desktop");

                                                                Prefs.folder2 = Folder("~/desktop");

                                                                Prefs.bits = false;

                                                            }

                                                            var win = new Window( 'dialog', 'RAW Converter' );

                                                            g = win.graphics;

                                                            var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.91, 0.91, 0.91, 1]);

                                                            g.backgroundColor = myBrush;

                                                            win.orientation = 'row';

                                                            win.p1 = win.add("panel", undefined, undefined, {borderStyle:"etched"});

                                                            win.g1 = win.p1.add('group');

                                                            win.g1.orientation = "row";

                                                            win.title = win.g1.add('statictext',undefined,'RAW to JPEG Converter');

                                                            win.title.alignment = "fill";

                                                            var g = win.title.graphics;

                                                            g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);

                                                            win.g5 = win.p1.add('group');

                                                            win.g5.orientation = "row";

                                                            win.g5.alignment = 'left';

                                                            win.g5.spacing = 10;

                                                            win.g5.st1 = win.g5.add('statictext',undefined,'Please select input folder');

                                                            win.g10 = win.p1.add('group');

                                                            win.g10.orientation = "row";

                                                            win.g10.alignment = 'left';

                                                            win.g10.spacing = 10;

                                                            win.g10.et1 = win.g10.add('edittext');

                                                            win.g10.et1.preferredSize = [400,20];

                                                            win.g10.et1.enabled = false;

                                                            win.g10.bu1 = win.g10.add('button',undefined,'Browse');

                                                            win.g10.bu1.onClick = function() {

                                                                InputFolder = Folder.selectDialog("Input folder",Prefs.folder1);

                                                                if(InputFolder != null){

                                                                    win.g10.et1.text = decodeURI(InputFolder.fsName);

                                                                    processHDRList();

                                                                }

                                                            }

                                                            win.g15 = win.p1.add('group');

                                                            win.g15.orientation = "row";

                                                            win.g15.alignment = 'left';

                                                            win.g15.spacing = 10;

                                                            win.g15.st1 = win.g15.add('statictext',undefined,'Please select output folder');

                                                            win.g20 = win.p1.add('group');

                                                            win.g20.orientation = "row";

                                                            win.g20.alignment = 'left';

                                                            win.g20.spacing = 10;

                                                            win.g20.et1 = win.g20.add('edittext');

                                                            win.g20.et1.preferredSize = [400,20];

                                                            win.g20.et1.enabled = false;

                                                            win.g20.bu1 = win.g20.add('button',undefined,'Browse');

                                                            win.g20.bu1.onClick = function() {

                                                                OutputFolder = Folder.selectDialog("Output folder",Prefs.folder2);

                                                                if(OutputFolder != null){

                                                                    win.g20.et1.text = decodeURI(OutputFolder.fsName);

                                                                }

                                                            }

                                                            win.g30 = win.p1.add('group');

                                                            win.g30.orientation = "row";

                                                            win.g30.alignment = 'right';

                                                            win.g30.spacing = 10;

                                                            win.g30.st1 = win.g30.add('statictext',undefined,'Please select conversion method');

                                                            win.g30.dd1 = win.g30.add('dropdownlist');

                                                            win.g30.dd1.preferredSize = [200,20];

                                                            var ConversionList = [];

                                                            ConversionList[0] = "Straight Conversion";

                                                            ConversionList[1] = "Bracketed 3x2EV to 7x2EV";

                                                            ConversionList[2] = "Bracketed 5x2EV to 9x2EV";

                                                            for(var x in ConversionList){

                                                                win.g30.dd1.add('item', ConversionList[x].toString());

                                                            }

                                                            win.g30.dd1.selection = 0;

                                                            var ConversionSel = win.g30.dd1.selection.text.toString();

                                                            win.g40 = win.p1.add('group');

                                                            win.g40.orientation = "row";

                                                            win.g40.alignment = 'right';

                                                            win.g40.spacing = 10;

                                                            win.g40.st2 = win.g40.add('statictext',undefined,'Please enter the exif exposure time of middle exposure');

                                                            win.g40.et1 = win.g40.add('edittext',undefined,'1');

                                                            win.g40.et1.preferredSize=[80,20];

                                                            win.g40.et1.enabled = true;

                                                            var TVsel = win.g40.et1.text.toString();

                                                            win.g50 = win.p1.add('group');

                                                            win.g50.orientation = "row";

                                                            win.g50.alignment = 'right';

                                                            win.g50.spacing = 10;

                                                            win.g50.cb1 = win.g50.add('checkbox',undefined,'Use XMP exposure time instead');

                                                            win.g50.cb1.helpTip = "Uses the xmp file's exposure time for the middle exposure instead";

                                                            win.g300 = win.p1.add('group');

                                                            win.g300.orientation = "row";

                                                            win.g300.alignment = 'center';

                                                            win.g300.spacing = 10;

                                                            win.g300.bu1 = win.g300.add('button',undefined,'Process');

                                                            win.g300.bu1.preferredSize = [240,30];

                                                            win.g300.bu2 = win.g300.add('button',undefined,'Cancel');

                                                            win.g300.bu2.preferredSize = [240,30];

                                                            win.g300.bu1.onClick = function(){

                                                                if(win.g10.et1.text == ''){

                                                                    alert("Input folder has not been selected!");

                                                                    return

                                                                }

                                                                if(win.g20.et1.text == ''){

                                                                    alert("Output folder has not been selected!");

                                                                    return

                                                                }

                                                                try{

                                                                Prefs.folder1 = InputFolder;

                                                                Prefs.folder2 = OutputFolder;

                                                                var progressBar = function(title) {

                                                                    var w = new Window( 'palette', ' '+title, {x:0, y:0, width:340, height:60} ),

                                                                    pb = w.add( 'progressbar', {x:20, y:12, width:300, height:12}, 0, 100 ),

                                                                    st = w.add( 'statictext', {x:10, y:36, width:320, height:20}, '' );

                                                                    st.justify = 'center';

                                                                    w.center();

                                                                    this.reset = function( msg,maxValue ) {

                                                                        st.text = msg;

                                                                        pb.value = 0;

                                                                        pb.maxvalue = maxValue||0;

                                                                        pb.visible = !!maxValue;

                                                                        w.show();

                                                                    };

                                                                    this.hit = function() { ++pb.value; };

                                                                    this.hide = function() { w.hide(); };

                                                                    this.close = function() { w.close(); };

                                                                    this.show = function() { w.show(); };

                                                                    this.update = function() { w.update(); };

                                                                    this.layout = function() { w.layout.layout(); };

                                                                };

                                                                function doPbar(){

                                                                    pBar.hit();

                                                                    pBar.hide();

                                                                    pBar.show();

                                                                }

                                                                var count = 0;

                                                                var group0 = InputFolder.getFiles(/\.(dng|crw|cr2|raw|raf|3fr|dcr|kdc|mrw|nef|nrw|orf|rw2|pef|x3f|srf| sr2)$/i);

                                                                var group1 = InputFolder.getFiles(/\e01.(dng|crw|cr2|raw|raf|3fr|dcr|kdc|mrw|nef|nrw|orf|rw2|pef|x3f|s rf|sr2)$/i);

                                                                var group2 = InputFolder.getFiles(/\e02.(dng|crw|cr2|raw|raf|3fr|dcr|kdc|mrw|nef|nrw|orf|rw2|pef|x3f|s rf|sr2)$/i);

                                                                var group3 = InputFolder.getFiles(/\e03.(dng|crw|cr2|raw|raf|3fr|dcr|kdc|mrw|nef|nrw|orf|rw2|pef|x3f|s rf|sr2)$/i);

                                                                var group4 = InputFolder.getFiles(/\e04.(dng|crw|cr2|raw|raf|3fr|dcr|kdc|mrw|nef|nrw|orf|rw2|pef|x3f|s rf|sr2)$/i);

                                                                var group5 = InputFolder.getFiles(/\e05.(dng|crw|cr2|raw|raf|3fr|dcr|kdc|mrw|nef|nrw|orf|rw2|pef|x3f|s rf|sr2)$/i);

                                                                count += group0.length;

                                                                count += group1.length;

                                                                count += group2.length;

                                                                count += group3.length;

                                                                count += group4.length;

                                                                count += group5.length;

                                                                if (count <1) return;

                                                                if (win.g30.dd1.selection == 0) {

                                                                    var pBar = new progressBar("RAW to JPEG Straight Conversion");

                                                                    pBar.reset("Processing Files", (group1.length*2));

                                                                    for(var a in group0){

                                                                        setEV(group0[a],0);

                                                                        open(group0[a]);

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

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group0[a]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + ".jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        doPbar();

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,TVval,0);

                                                                    }

                                                                    pBar.close();

                                                                } else

                                                                if (win.g30.dd1.selection == 1) {

                                                                    var pBar = new progressBar("3 RAWs by 2 EV to 7 JPEGs by 2 EV");

                                                                    pBar.reset("Processing E01 Files", (group1.length*2));

                                                                    for(var a in group1){

                                                                        setEV(group1[a],-4);

                                                                        open(group1[a]);

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

                                                                        Name = Name.replace(/e01$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group2[a]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E01.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/64"),-6);

                                                                        doPbar();

                                                                        setEV(group1[a],-2);

                                                                        open(group1[a]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E02.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/16"),-4);

                                                                        doPbar();

                                                                    }

                                                                    pBar.reset("Processing E02 Files", (group2.length*3));

                                                                    for(var b in group2){

                                                                        setEV(group2[b],-2);

                                                                        open(group2[b]);

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

                                                                        Name = Name.replace(/e02$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group2[b]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E03.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/4"),-2);

                                                                        doPbar();

                                                                        setEV(group2[b],0);

                                                                        open(group2[b]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E04.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,TVval,0);

                                                                        doPbar();

                                                                        setEV(group2[b],2);

                                                                        open(group2[b]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E05.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"4"),2);

                                                                        doPbar();

                                                                    }

                                                                    pBar.reset("Processing E03 Files", (group3.length*2));

                                                                    for(var c in group3){

                                                                        setEV(group3[c],2);

                                                                        open(group3[c]);

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

                                                                        Name = Name.replace(/e03$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group2[c]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E06.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"16"),4);

                                                                        doPbar();

                                                                        setEV(group3[c],4);

                                                                        open(group3[c]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E07.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        doPbar();

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"64"),6);

                                                                    }

                                                                    pBar.close();

                                                                } else

                                                                if (win.g30.dd1.selection == 2) {

                                                                    var pBar = new progressBar("5 RAWs by 2 EV to 9 JPEGs by 2 EV");

                                                                    pBar.reset("Processing E01 Files", (group1.length*2));

                                                                    for(var a in group1){

                                                                        setEV(group1[a],-4);

                                                                        open(group1[a]);

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

                                                                        Name = Name.replace(/e01$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group3[a]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E01.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/256"),-8);

                                                                        doPbar();

                                                                    }

                                                                    pBar.reset("Processing E02 Files", (group2.length*3));

                                                                    for(var b in group2){

                                                                        setEV(group2[b],-4);

                                                                        open(group2[b]);

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

                                                                        Name = Name.replace(/e02$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group3[b]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E02.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/64"),-6);

                                                                        doPbar();

                                                                        setEV(group2[b],-2);

                                                                        open(group2[b]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E03.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/16"),-4);

                                                                        doPbar();

                                                                    }

                                                                    pBar.reset("Processing E03 Files", (group3.length*3));

                                                                    for(var c in group3){

                                                                        setEV(group3[c],-2);

                                                                        open(group3[c]);

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

                                                                        Name = Name.replace(/e03$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group3[c]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E04.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"1/4"),-2);

                                                                        doPbar();

                                                                        setEV(group3[c],0);

                                                                        open(group3[c]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E05.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,TVval,0);

                                                                        doPbar();

                                                                        setEV(group3[c],2);

                                                                        open(group3[c]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E06.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"4"),2);

                                                                        doPbar();

                                                                    }

                                                                    pBar.reset("Processing E04 Files", (group4.length*3));

                                                                    for(var d in group4){

                                                                        setEV(group4[d],2);

                                                                        open(group4[d]);

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

                                                                        Name = Name.replace(/e04$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group3[d]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E07.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"16"),4);

                                                                        doPbar();

                                                                        setEV(group4[d],4);

                                                                        open(group4[d]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E08.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"64"),6);

                                                                        doPbar();

                                                                    }

                                                                    pBar.reset("Processing E05 Files", (group3.length*2));

                                                                    for(var e in group5){

                                                                        setEV(group5[e],4);

                                                                        open(group5[e]);

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

                                                                        Name = Name.replace(/e05$/i,'');

                                                                        var TVval = TVsel;

                                                                        if (win.g50.cb1.value) TVval = getEV(group3[e]);

                                                                        var exportFile = new File( OutputFolder + "/" + Name + "E09.jpg" );

                                                                        SaveForWeb(exportFile,100);

                                                                        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                                                                        putXMPData(exportFile,ExifEV(String(TVval),"256"),8);

                                                                        doPbar();

                                                                    }

                                                                    pBar.close();

                                                                }

                                                                var desc2 = new ActionDescriptor();

                                                                desc2.putString(0, Prefs.toSource());

                                                                app.putCustomOptions('0bafbed0-0bc7-11e1-be50-0800200c9a66', desc2, true );

                                                                win.close(0);

                                                                }catch(e){alert(e + " - " +e.line);}

                                                            }

                                                            win.center();

                                                            win.show();

                                                            app.displayDialogs = DialogModes.NO;

                                                        }

                                                        function ExifEV(Input,Multiplier) {

                                                            var EVval = Math.abs(eval(Input)*eval(Multiplier)); // Positive Decimal

                                                            var EVvalN = 1; // Numerator

                                                            var EVvalD = 1; // Denominator

                                                            if (EVval < 0.5) EVvalD = Math.floor(1/EVval); else // For values less than 1/2

                                                            // For values greater than 1/2 or values less than 1-1/2, returns 1000ths

                                                            if (EVval < 1 || EVval > 1) {

                                                                EVvalN = Math.floor(EVval*1000);

                                                                EVvalD = 1000;

                                                            } else                                   

                                                            if (EVval > 1.5) EVvalN = Math.floor(EVval); // For values greater than 1-1/2

                                                            return String(EVvalN + "/" + EVvalD); // Return fraction

                                                        }

                                                        function getEV(thumb){

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

                                                            var file = new File(thumb.path + "/" + Name + ".xmp");

                                                            try{

                                                                if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

                                                                if(file.exists){

                                                                    file.open('r');

                                                                    file.encoding = "UTF8";

                                                                    file.lineFeed = "unix";

                                                                    file.open("r", "TEXT", "????");

                                                                    var xmpStr = file.read();

                                                                    file.close();

                                                                }else{

                                                                    var xmpStr='';

                                                                }

                                                                var xmp = new XMPMeta( xmpStr );

                                                                var exposureTime = xmp.getProperty(XMPConst.NS_EXIF, 'ExposureTime');

                                                                if(exposureTime  == undefined) exposureTime = 1;

                                                            }catch(e){alert(e+"-"+e.line);}

                                                            return exposureTime;

                                                        };

                                                        function setEV(thumb,evValue){

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

                                                            var file = new File(thumb.path + "/" + Name + ".xmp");

                                                            try{

                                                                if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

                                                                if(file.exists){

                                                                    file.open('r');

                                                                    file.encoding = "UTF8";

                                                                    file.lineFeed = "unix";

                                                                    file.open("r", "TEXT", "????");

                                                                    var xmpStr = file.read();

                                                                    file.close();

                                                                }else{

                                                                    var xmpStr='';

                                                                }

                                                                var xmp = new XMPMeta( xmpStr );

                                                                var exposureValue = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Exposure");

                                                                xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure");

                                                                xmp.setProperty(XMPConst.NS_CAMERA_RAW, "Exposure",Number(evValue));

                                                                file.open('w');

                                                                file.encoding = "UTF8";

                                                                file.lineFeed = "unix";

                                                                file.write( xmp.serialize() );

                                                                file.close();

                                                                if(exposureValue  == undefined) exposureValue = 0;

                                                            }catch(e){alert(e+"-"+e.line);}

                                                            return exposureValue;

                                                        };

                                                        function putXMPData(fileName,exposureTime,evValue){

                                                            if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

                                                            var xmpf = new XMPFile(fileName.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE | XMPConst.OPEN_USE_SMART_HANDLER );

                                                            var xmp = xmpf.getXMP();

                                                            try{

                                                                xmp.setProperty(XMPConst.NS_TIFF, 'Make', 'Canon');

                                                                xmp.setProperty(XMPConst.NS_TIFF, 'Model', 'Canon EOS REBEL T1i');

                                                                xmp.setProperty(XMPConst.NS_EXIF, 'ExposureTime', exposureTime);

                                                                xmp.setProperty(XMPConst.NS_EXIF, 'FNumber', '63/10');

                                                                xmp.setProperty(XMPConst.NS_CAMERA_RAW, 'Exposure',Number(evValue));

                                                                if (xmpf.canPutXMP(xmp)) {

                                                                        xmpf.putXMP(xmp);

                                                                    }else{

                                                                        alert(e.message);

                                                                    }

                                                                    xmpf.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

                                                            }catch(e){}

                                                        }

                                                        function SaveForWeb(saveFile,jpegQuality) {

                                                            var sfwOptions = new ExportOptionsSaveForWeb();

                                                            sfwOptions.format = SaveDocumentType.JPEG;

                                                            sfwOptions.includeProfile = false;

                                                            sfwOptions.interlaced = 0;

                                                            sfwOptions.optimized = true;

                                                            sfwOptions.quality = jpegQuality;

                                                            activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

                                                        }

                                                         

                                                        The script seems to work decent, so I plan on adding the other conversions I mentioned earlier, to it.  If there is a way of getting the exposure time directly from the raw file, please let me know.