Skip to main content
bagonterman
Inspiring
March 15, 2013
Answered

Only Select RGB Files?

  • March 15, 2013
  • 1 reply
  • 725 views

I am creating a script to only select RGB Files. I am having problems with the Array because affter I am done its empty.

I was hoping to make a list of RGB files and then select them, But I have not been able to create a list yet.

#target bridge

app.document.deselectAll();

var thumbs = app.document.getSelection("jpg");

for(var a in thumbs){

var RGBlist=[];

var poop=app.document.select(app.document.thumbnail.children) ;

var isRGB=app.document.selections[0].core.quickMetadata.colorMode;

var picSelect=app.document.selections[0];

if(isRGB==3){

    RGBlist.push(picSelect.name);

     }

var noSelect=app.document.deselect(app.document.thumbnail.children);

alert(RGBlist);

}

Any Ideas?

This topic has been closed for replies.
Correct answer Muppet Mark

The core data returns an integer value not a string… 3 being RGB.

#target bridge

app.document.deselectAll();

var count = app.document.visibleThumbnailsLength;

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

   

    if ( app.document.visibleThumbnails.core.quickMetadata.colorMode == 3 ) {

       

        app.document.select( app.document.visibleThumbnails );

       

    };

};

1 reply

Muppet MarkCorrect answer
Inspiring
March 15, 2013

The core data returns an integer value not a string… 3 being RGB.

#target bridge

app.document.deselectAll();

var count = app.document.visibleThumbnailsLength;

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

   

    if ( app.document.visibleThumbnails.core.quickMetadata.colorMode == 3 ) {

       

        app.document.select( app.document.visibleThumbnails );

       

    };

};

bagonterman
Inspiring
March 15, 2013

Holy ship batman. Thanks my approach was wrong I think. I knew that it returned 3 but I thought i was storing the objects in an array. Anyway as confused as I am thank you because it works.

bagonterman
Inspiring
March 15, 2013

Yeah you checked the quickMetadata first and then selected. Much simpler.