• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Detect present rating

Enthusiast ,
Sep 27, 2011 Sep 27, 2011

Copy link to clipboard

Copied

I want a function to detect if the info of an image (not new, but opened from the disk) has indicated a rating (1, 2, 3, 4 or 5 stars)?

I want to open the ACR and (only in some images) mark them with 1 star.

In photoshop, when they are all already opened, I want to diferenciate a behavior of the script depending on the detection of the rating (stars).

Is this possible?

Tks

TOPICS
Actions and scripting

Views

755

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 27, 2011 Sep 27, 2011

Does this work?

// from a post by michael l hale;

var rating = app.activeDocument.xmpMetadata.rawData.toString().match(/\<xmp:Rating\>(.+)\<\/xmp:Rating\>/)[1];

alert (rating);

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 27, 2011 Sep 27, 2011

Copy link to clipboard

Copied

Does this work?

// from a post by michael l hale;

var rating = app.activeDocument.xmpMetadata.rawData.toString().match(/\<xmp:Rating\>(.+)\<\/xmp:Rating\>/)[1];

alert (rating);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

LATEST

Here is some code that our developer created.  It views the documents photoshop rating and saves to a new location with a new name based on the rating.  It works great.  Oh, and you'll see in there that a dialogue window pops up with radio buttons if no photoshop rating is found.  Then the user can choose 1 - 5 based on where it should be going.

loadXMPLibrary();

var xmp = new XMPMeta(docRef.xmpMetadata.rawData);

documentRating = xmp.getProperty(XMPConst.NS_XMP, "Rating");

var FillColour = new SolidColor;

FillColour.rgb.hexValue = 'ffffff';

app.backgroundColor= FillColour;

if(documentRating!=undefined && documentRating.value!=0){

    hasRating = true;

}

else{

    var dlg = new Window("dialog", "Choose Position");

    dlg.alertBtnsPnl = dlg.add("panel", undefined, PANEL_MESSAGE_TEXT);

    dlg.alertBtnsPnl.p1Btn = dlg.alertBtnsPnl.add("radiobutton", undefined, positionStringArray[0]);

    dlg.alertBtnsPnl.p2Btn = dlg.alertBtnsPnl.add("radiobutton", undefined, positionStringArray[1]);

    dlg.alertBtnsPnl.p3Btn = dlg.alertBtnsPnl.add("radiobutton", undefined, positionStringArray[2]);

    dlg.alertBtnsPnl.p4Btn = dlg.alertBtnsPnl.add("radiobutton", undefined, positionStringArray[3]);

    dlg.alertBtnsPnl.p5Btn = dlg.alertBtnsPnl.add("radiobutton", undefined, positionStringArray[4]);

    dlg.alertBtnsPnl.p6Btn = dlg.alertBtnsPnl.add("radiobutton", undefined, positionStringArray[5]);

    dlg.alertBtnsPnl.okBtn = dlg.alertBtnsPnl.add("button", undefined, "OK", {name:"ok"});

    dlg.alertBtnsPnl.cancelBtn = dlg.alertBtnsPnl.add("button", undefined, "Cancel", {name:"cancel"});

    var dialogReturn = dlg.show();

    if(dialogReturn==1){//if dialogReturn is one, the ok button was clicked, if it equals 2 the cancel button was clicked

        if(dlg.alertBtnsPnl.p1Btn.value){documentRating=1;};

        if(dlg.alertBtnsPnl.p2Btn.value){documentRating=2;};

        if(dlg.alertBtnsPnl.p3Btn.value){documentRating=3;};

        if(dlg.alertBtnsPnl.p4Btn.value){documentRating=4;};

        if(dlg.alertBtnsPnl.p5Btn.value){documentRating=5;};

        if(dlg.alertBtnsPnl.p6Btn.value){documentRating=6;};

    }

}

if(documentRating==undefined){

    if(dialogReturn!=2){

        alert ("You've failed to select a rating, please try again");

    }

}

else if(dialogReturn!=2){

    selRef.makeWorkPath(0);

    var thisWorkPath = docRef.pathItems.getByName("Work Path");

    thisWorkPath.makeSelection();

    try{

        var existingWorkPath = docRef.pathItems.getByName(PATH_TEXT);

        existingWorkPath.remove();

    }

    catch(e){

    }

    thisWorkPath.name = PATH_TEXT;

    xmp.setProperty(XMPConst.NS_XMP, "Rating", documentRating);

    docRef.xmpMetadata.rawData = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines