Although you can read the rawdata into a script to parse with Photoshop you can't write it back. You could with Bridge but I would suggest that you use the XMPLibrary. The script below has the needed functions and an example of how to read and set both Rating and Label. Note it only works with CS4 because it needs the library. var f = File.openDialog ( undefined, undefined, false ); setRating( f, "5" ); setLabel( f, "Green" ); alert( getLabelAndRating( f ) ); function getLabelAndRating( file ){// File object try{ loadXMPLibrary(); var xmpf = new XMPFile( file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ ); var xmp = xmpf.getXMP(); xmpf.closeFile(); var Label = xmp.getProperty( XMPConst.NS_XMP, "Label" ).toString(); var Rating = xmp.getProperty( XMPConst.NS_XMP, "Rating" ).toString(); }catch(e){} return [ Label, Rating ]; unloadXMPLibrary(); } function setRating( file, rating ){// File object, String try{ loadXMPLibrary(); var xmpf = new XMPFile( file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE); var xmp = xmpf.getXMP(); xmp.setProperty( XMPConst.NS_XMP, "Rating", rating ); xmpf.putXMP( xmp ); xmpf.closeFile(); }catch(e){ unloadXMPLibrary(); return -1; } unloadXMPLibrary(); } function setLabel( file, label ){// File object, String try{ loadXMPLibrary(); var xmpf = new XMPFile( file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE); var xmp = xmpf.getXMP(); xmp.setProperty( XMPConst.NS_XMP, "Label", label ); xmpf.putXMP( xmp ); xmpf.closeFile(); }catch(e){ unloadXMPLibrary(); return -1; } unloadXMPLibrary(); } /** The function loads the XMP Script Library. @returns True if the XMP Script Library was loaded successfully. @type Boolean */ function loadXMPLibrary(){ if ( !ExternalObject.AdobeXMPScript ){ try{ ExternalObject.AdobeXMPScript = new ExternalObject ('lib:AdobeXMPScript'); }catch (e){ alert( ErrStrs.XMPLIB ); return false; } } return true; } /** The function unloads the XMP Script Library. */ function unloadXMPLibrary(){ if( ExternalObject.AdobeXMPScript ) { try{ ExternalObject.AdobeXMPScript.unload(); ExternalObject.AdobeXMPScript = undefined; }catch (e){ alert( ErrStrs.XMPLIB ); } } }
... View more