Skip to main content
Known Participant
May 29, 2017
Answered

Stacking stray images

  • May 29, 2017
  • 1 reply
  • 927 views

I have a bizarre need.  I need to locate unstacked images and add them to the previous stack (by previous stack, i mean the stack of images taken immediately before the unstacked image)

I know some javascript, but I'm a newbie at adobe, so I can't figure out how to

1) ID unstacked images

2) ID the stack immediately previous to it

3) add the new image to the stack (and when I do this, will the stack be in chronological order?)

thanks

This topic has been closed for replies.
Correct answer SuperMerlin

You could give the following script a try, it is very basic and no error checking is done. Any stray files should be added to the previous stack.

The stray document will be at the top of the stack.

N.B. There must be a stack file at the begining of the content window.

It was written for the odd single files between stacks.

#target bridge  

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

strayStacks = new MenuElement("command", "Add stray pics to stack",  "at the end of submenu/Stack");

}

strayStacks.onSelect = function () {

app.document.chooseMenuItem("CollapseAllStacks");

var count = app.document.visibleThumbnails.length;

var stackCount = app.document.stacks.length;

var files = new Array();

for (var a = 0;a< count;a++){

    files.push([,[app.document.visibleThumbnails.spec],[9999]]);

    }

for(var b = 0;b<stackCount;b++){

    var sFiles = getStackFiles(app.document.stacks);

    for(var sF =0; sF<sFiles.length;sF++){

        for(var t = 0;t<files.length;t++){

            if(sFiles[sF].toString() == files[1].toString()) files[2] = b;

            }

        }

    }

for(var z =0;z<files.length;z++){

    if(Number(files[2]) == 9999){

        app.document.deselectAll();

        app.document.select(new Thumbnail (File(files[1].toString())));

        app.document.select(new Thumbnail (File(files[z-1][1].toString())));

        app.document.chooseMenuItem("StackUngroup");

        app.document.chooseMenuItem("StackGroup");

        }

    }

function getStackFiles( stack ){

      var files = new Array();

      for( var f = 0; f<stack.thumbnails.length;f++){

           files.push(stack.thumbnails.spec);

      }

      return files;

};

};

SuperMerlin
SuperMerlinCorrect answer
Inspiring
May 29, 2017

You could give the following script a try, it is very basic and no error checking is done. Any stray files should be added to the previous stack.

The stray document will be at the top of the stack.

N.B. There must be a stack file at the begining of the content window.

It was written for the odd single files between stacks.

#target bridge  

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

strayStacks = new MenuElement("command", "Add stray pics to stack",  "at the end of submenu/Stack");

}

strayStacks.onSelect = function () {

app.document.chooseMenuItem("CollapseAllStacks");

var count = app.document.visibleThumbnails.length;

var stackCount = app.document.stacks.length;

var files = new Array();

for (var a = 0;a< count;a++){

    files.push([,[app.document.visibleThumbnails.spec],[9999]]);

    }

for(var b = 0;b<stackCount;b++){

    var sFiles = getStackFiles(app.document.stacks);

    for(var sF =0; sF<sFiles.length;sF++){

        for(var t = 0;t<files.length;t++){

            if(sFiles[sF].toString() == files[1].toString()) files[2] = b;

            }

        }

    }

for(var z =0;z<files.length;z++){

    if(Number(files[2]) == 9999){

        app.document.deselectAll();

        app.document.select(new Thumbnail (File(files[1].toString())));

        app.document.select(new Thumbnail (File(files[z-1][1].toString())));

        app.document.chooseMenuItem("StackUngroup");

        app.document.chooseMenuItem("StackGroup");

        }

    }

function getStackFiles( stack ){

      var files = new Array();

      for( var f = 0; f<stack.thumbnails.length;f++){

           files.push(stack.thumbnails.spec);

      }

      return files;

};

};

cutch2222Author
Known Participant
May 30, 2017

You, sir, have earned your named.

Thank you.