Issue with setting ratings and labels
Greetings all. I am having an issue with setting ratings AND labels on image files at the same time. If the script sets the label first then the rating, the label doesn't show in Bridge. If the script sets the rating first then the label, the rating doesn't show in Bridge.
Is there a workaround for this? Here is my script function for doing this. file=filename minus extension. Rating is a number for the desired rating. lab is a number for the level of Label I wish to set. Everything works great except that I can't set both Rating and Label with the script as shown. In this instance, only the Ratings will show up in Bridge after running the script. If I move the x.label=Label line under the x.rating=Rating line, then the ratings only show for those images with no label (lab=0). Any image that gets a label receives no rating.
If you're going to test this, you may want to comment out the Collections part. That's the part within the "switch(Number(Rating))" block.
function setRating(file,Rating,lab) {
try{
cr=File(file+"CR2");
psd=File(file+"psd");
jpg=File(file+"jpg");
tif=File(file+"tif");
switch(lab) {
case 0: Label = ""; break;
case 1: Label = "Select"; break;
case 2: Label = "Second"; break;
case 3: Label = "Approved"; break;
}
if (cr.created) {
var c=new Thumbnail(cr);
c.label=Label;
c.rating=Rating;
if (psd.created) {
p=new Thumbnail(psd);
p.label=Label;
p.rating=Rating;
if (jpg.created) {
var j=new Thumbnail(jpg);
j.label=Label;
j.rating=Rating;
Rating=0;
}
else addFile=psd;
}
else addFile=cr;
}
switch(Number(Rating)){
case 0 : break; /* No Rating */
case 1 : if(!app.isCollectionMember(OneStar,new Thumbnail(addFile))) app.addCollectionMember(OneStar,new Thumbnail(addFile)); break;
case 2 : if(!app.isCollectionMember(TwoStars,new Thumbnail(addFile))) app.addCollectionMember(TwoStars,new Thumbnail(addFile)); break;
case 3 : if(!app.isCollectionMember(ThreeStars,new Thumbnail(addFile))) app.addCollectionMember(ThreeStars,new Thumbnail(addFile)); break;
case 4 : if(!app.isCollectionMember(FourStars,new Thumbnail(addFile))) app.addCollectionMember(FourStars,new Thumbnail(addFile)); break;
case 5 : if(!app.isCollectionMember(FiveStars,new Thumbnail(addFile))) app.addCollectionMember(FiveStars,new Thumbnail(addFile)); break;
default : break;
}
}catch(e){
alert(e);
return -1;
}
}