Photoshop: Saving Photoshop Script Document Properties

  • 2
  • Question
  • Updated 7 years ago
  • Answered
  • (Edited)
I am writing a VB app that opens a RAW file under Photoshop scripting, updates the document's Info.Title and Info.Caption properties, then saves.

doc.Save doesn't seem to work, as this attempts a PSD save. I have tried various SaveAs options, but all these seem to want to save a copy. I want to update just these two properties on the original document.

Any help out there, anyone?

Thanks in advance.

Brad
Photo of Brad Varey

Brad Varey

  • 2 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 2
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Raw files are read only! You can update the metadata in the xmp sidecar using javaScript via Photoshop or Bridge.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 823 Reply Likes
If you changed something in the document that won't work in the current (opened) file format, then Photoshop defaults to saving PSD.

And, as Paul pointed out, Camera RAW files cannot be saved, so saving them must default to PSD.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
You might me able to pass the javaScript by the "DoJavaScript" command?
Here is one way of updating the metadata without open the Camera Raw file.


#target photoshop
var xmpFile = new File( "/c/folderName/folderName/fileName.xmp" );

var Title = "This is the best Photo ever";
var Caption = "This is also known as the description field";
setMetadata( xmpFile, Title, Caption );

function setMetadata( file, Title, Caption ){
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{
var xmpStr='';
}
var xmp = new XMPMeta( xmpStr );
if(Title != ''){
xmp.deleteProperty(XMPConst.NS_DC, "title");
xmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 0, XMPConst.ALIAS_TO_ALT_TEXT);
xmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
}
if(Caption != ''){
xmp.deleteProperty(XMPConst.NS_DC, "description");
xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Caption );
}
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
};