Skip navigation
Currently Being Moderated

Using RAW+JPEG stacking script, but can't get JPEG as default thumbnail for stack. Help!

Apr 21, 2012 5:24 PM

I am currently using this script I found elsewhere on Adobe forums. However, doing this function only will stack everything with the raw files on top. I am using a 5D MKIII now and Bridge CS4 can't generate the CR2 previews, so I need JPEGs to see what a file is for general editing. How do I get this stack script to put the JPEGS on top instead of the raw files?

 

(script originally posted by Paul Riggot in another forum)

 

 

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

AutoStack = MenuElement.create("command", "Auto Stack", "at the beginning of submenu/Stack", "zx1");

}

AutoStack.onSelect = function () {

   stackEm();

   }

function stackEm(){

app.document.sorts = [{ name:"name",type:"string", reverse:false}];

var jpgs = Folder(app.document.presentationPath).getFiles ("*.jpg");

app.document.deselectAll();

for(var a in jpgs){

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

var stacks = Folder(app.document.presentationPath).getFiles(Name+".*");

if(stacks.length < 2) continue;

for(var z in stacks){ app.document.select(new Thumbnail(stacks[z]));}

StackFiles();

app.document.deselectAll();

}

function StackFiles(){

app.document.chooseMenuItem('submenu/Stack');

app.document.chooseMenuItem('StackGroup');

 
Replies
  • Currently Being Moderated
    Apr 22, 2012 2:13 AM   in reply to Beefsticks

    Hopfully this should work now, I have now changed the sort order so the jpg is first...

     

     

    #target bridge   
    if( BridgeTalk.appName == "bridge" ) {  
    AutoStack = MenuElement.create("command", "Auto Stack", "at the beginning of submenu/Stack", "zx1");
    }
    AutoStack.onSelect = function () { 
    app.document.sorts = [{ name:"name",type:"string", reverse:true}]; 
    var jpgs = Folder(app.document.presentationPath).getFiles ("*.jpg");
    app.document.deselectAll();
    for(var a in jpgs){
    var Name = decodeURI(jpgs[a].name).replace(/\.[^\.]+$/, '');
    var stacks = Folder(app.document.presentationPath).getFiles(Name+".*");
    if(stacks.length < 2) continue;
    for(var z in stacks){ app.document.select(new Thumbnail(stacks[z]));}
    app.document.chooseMenuItem('StackGroup');
    app.document.deselectAll();
    }
    app.document.sorts = [{ name:"name",type:"string", reverse:false}]; 
    }
    
    
     
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2012 9:37 AM   in reply to Beefsticks

    What you can do is select all the stacks then Stacks - Open Stack, you can then select the documents you want to rate/label. To close select all stacks and Stacks - Close Stack.

    The script won't change the normal behaviour.

     

    Hope this helps.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2012 3:04 PM   in reply to Beefsticks

    I wonder if you have time if you could test this script for me please?

    What it does (tries to do) is to create JPGs from the raw files in the same folder as the CR2 (raw) files.

    N.B. IT WILL OVERWRITE ANY JPGS IN THE SAME FOLDER IF THE NAMES MATCH!

    So please try it on a folder with raw files only.

    The idea being it might be quicker to generate jpegs from the embedded thumbnail rather than shoot both raw/jpg?

     

    T.I.A.

     

     

    #target bridge   
    if( BridgeTalk.appName == "bridge" ) {  
    AutoStackJpgs = MenuElement.create("command", "Create Stack JPGs", "at the beginning of submenu/Stack", "sj1");
    }
    AutoStackJpgs .onSelect = function () { 
    app.document.deselectAll();
    var items = app.document.getSelection("crw,cr2,tiff,raw,rw2,dng,nef,orf,erf,mos,dcr,raf,srf,pef,x3f");
     for (var a =0; a<items.length;a++){
    var JPEG = new File(items[a].path.substr(0,items[a].path.lastIndexOf ('.'))+".jpg");
    tempFile=new File(items[a].path);
    var fileString='';
    tempFile.open('r');
    tempFile.encoding = 'BINARY'; 
    fileString=tempFile.read();
    tempFile.close();
    for(var w =0;w<6;w++){
    var startJpg=fileString.search(/\xFF\xD8\xFF/);
    if(startJpg != -1){
    if(testJPG()){
    var endJpg = fileString.search(/\xFF\xD9/);
    fileString = fileString.substr(0,endJpg+2);
    JPEG.open('w');
    JPEG.encoding = 'BINARY';
    JPEG.write(fileString);
    JPEG.close();
    var newThumb = new Thumbnail(JPEG);
    newThumb.rotation = items[a].rotation;
    break;
    }else{
    fileString = fileString.substr(20);
     continue;
    }}}
    function testJPG(){
    var result=false;
    fileString = fileString.substr(startJpg);
    var endTest = fileString.search(/\xFF\xD9/);
    if(endTest > 204800 ? result= true : result= false);
    return result;
      }
     }
    }
    
    
     
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 12:54 AM   in reply to Beefsticks

    Thank you very much for the detailed report. I only have a 5D MK1 so didn't know if it would work with newer models.

     

    The jpegs should be smaller as no metadata is being transfered from the raw file, I have added a check so that existing jpgs are not overwritten.

    Hope it may be of use to you.

     

     

    #target bridge   
    if( BridgeTalk.appName == "bridge" ) {  
    AutoStackJpgs = MenuElement.create("command", "Create Stack JPGs", "at the beginning of submenu/Stack", "sj1");
    }
    AutoStackJpgs .onSelect = function () { 
    app.document.deselectAll();
    var items = app.document.getSelection("crw,cr2,tiff,raw,rw2,dng,nef,orf,erf,mos,dcr,raf,srf,pef,x3f");
     for (var a =0; a<items.length;a++){
    var JPEG = new File(items[a].path.substr(0,items[a].path.lastIndexOf ('.'))+".jpg");
    if(JPEG.exists) continue;
    tempFile=new File(items[a].path);
    var fileString='';
    tempFile.open('r');
    tempFile.encoding = 'BINARY'; 
    fileString=tempFile.read();
    tempFile.close();
    for(var w =0;w<6;w++){
    var startJpg=fileString.search(/\xFF\xD8\xFF/);
    if(startJpg != -1){
    if(testJPG()){
    var endJpg = fileString.search(/\xFF\xD9/);
    fileString = fileString.substr(0,endJpg+2);
    JPEG.open('w');
    JPEG.encoding = 'BINARY';
    JPEG.write(fileString);
    JPEG.close();
    var newThumb = new Thumbnail(JPEG);
    newThumb.rotation = items[a].rotation;
    break;
    }else{
    fileString = fileString.substr(20);
     continue;
    }}}
    function testJPG(){
    var result=false;
    fileString = fileString.substr(startJpg);
    var endTest = fileString.search(/\xFF\xD9/);
    if(endTest > 204800 ? result= true : result= false);
    return result;
      }
     }
    }
    
    
     
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 31, 2012 3:27 PM   in reply to Paul Riggott

    Hi Paul!

     

    I am starting to use Adobe Bridge now and I found your post was exactly my solution to my problem - I wanted to stack both the JPEG and RAW together.

     

    I have two questions (which I will probably eventually find out, but I want to ask you first and search for my answer)

     

    1) What line to do add this script to on the JSX file? Or is it a separate file that you add to the startup script folder (you make another .jsx file?)

     

    2) If I have both the RAW and JPEG stacked, will me rating that stack effect both the JPEG and RAW (XML)?

     

    Thank you so much!
    Happy New Year,

    Justin

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 2, 2013 11:47 AM   in reply to jkunimoto22

    The above script should be saved with a .jsx extension and saved into the start-up folder that can be found by going to the Bridge preferences - Startup Scripts and clicking the "Reveal My Startup Scripts"

     

    A rating added to a stack will only be done to the top thumbnail.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 2, 2013 12:06 PM   in reply to Paul Riggott

    Okay!

    I just created a .jsx extension file with the code above (directly copied and pasted)

     

    The directoy of the .jsx extension is:
    C:\Users\(myuserrname)\AppData\Roaming\Adobe\Bridge CS5\Startup Scripts

     

    Yes, I am using AdobeBridge CS5.

    I have enabled the file via the start-up script preferences. When I restarted bridge it asked me if I wanted to use this script (clicked 'yes').

    Also, I have named the script file, "stacking.jsx"

     

    I have no idea what I am doing which doesn't allow the CR2 (canon RAW) and the jpgs to stack.

     

    Thank you for everything,

    Justin

     

    -- Thank you about the rating tip as well

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 2, 2013 12:25 PM   in reply to jkunimoto22

    To run the script go Stacks  and select Auto Stack.

     

    Hope this helps.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 2, 2013 1:50 PM   in reply to Paul Riggott

    SUCCESS!!

     

    Thank you!!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points