Hi there,
i'm a complete newbie to PS-Scripting and have a problem to solve. Hopefully someone can help me on this:
i am handing Jpeg-Files to PhotoshopCS4 with Enfocus Powerswitch on a Macintosh, then the Script has to check if there is a Pathitem called "Path 1". On success a new Metadatafield called "Path 1" of Type "Boolean" has to be created and set to "1" and the Action "W-S-Path" from Action-Set "SWITCH" has to be called. On failure a new Metadatafield called "Path 1" of Type "Boolean" has to be created and set to "0".
I hope that its possible to get that done somehow, as i have no clue
Thanks in advance.
patrick
Check if Pathitem exists and set Metadata accordingly
-
Paul MR
Check if Pathitem exists and set Metadata accordingly
You can't have a metadata field with a space in it, so this uses Path_1 ...
Code: Select allmain();
function main(){
if(!documents.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var psNamespace = "http://ns.pathInfo/1.0/";
var psPrefix = "path:";
XMPMeta.registerNamespace(psNamespace, psPrefix);
xmp = new XMPMeta( app.activeDocument.xmpMetadata.rawData );
xmp.deleteProperty(psNamespace, "Path_1");
try{
var path = activeDocument.pathItems["Path 1"];
xmp.setProperty(psNamespace, "Path_1",1);
app.doAction("W-S-Path" , "SWITCH");
}catch(e){
xmp.setProperty(psNamespace, "Path_1",0);
}
app.activeDocument.xmpMetadata.rawData = xmp.serialize();
}
Code: Select allmain();
function main(){
if(!documents.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var psNamespace = "http://ns.pathInfo/1.0/";
var psPrefix = "path:";
XMPMeta.registerNamespace(psNamespace, psPrefix);
xmp = new XMPMeta( app.activeDocument.xmpMetadata.rawData );
xmp.deleteProperty(psNamespace, "Path_1");
try{
var path = activeDocument.pathItems["Path 1"];
xmp.setProperty(psNamespace, "Path_1",1);
app.doAction("W-S-Path" , "SWITCH");
}catch(e){
xmp.setProperty(psNamespace, "Path_1",0);
}
app.activeDocument.xmpMetadata.rawData = xmp.serialize();
}
-
djonyx
Check if Pathitem exists and set Metadata accordingly
Hi Paul,
Many thanks for your quick reply and your script! I'll try it immediately and let you know the results!
this looks great!
Many thanks for your quick reply and your script! I'll try it immediately and let you know the results!
this looks great!
-
djonyx
Check if Pathitem exists and set Metadata accordingly
Hi Paul,
you made my day, works like a charm!
Thanks a lot and have a nice day!
patrick
you made my day, works like a charm!
Thanks a lot and have a nice day!
patrick
-
jschober
Check if Pathitem exists and set Metadata accordingly
Is it possible to change the script that it checks if any path exists or not?
Kind regards,
Jörg
Kind regards,
Jörg
-
Paul MR
Check if Pathitem exists and set Metadata accordingly
Yes, you could do something like this...
Code: Select allmain();
function main(){
if(!documents.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var psNamespace = "http://ns.pathInfo/1.0/";
var psPrefix = "path:";
XMPMeta.registerNamespace(psNamespace, psPrefix);
xmp = new XMPMeta( app.activeDocument.xmpMetadata.rawData );
xmp.deleteProperty(psNamespace, "Path_1");
if(activeDocument.pathItems.length >0){
xmp.setProperty(psNamespace, "Path_1",1);
//amend action to suit
//app.doAction("W-S-Path" , "SWITCH");
}else{
xmp.setProperty(psNamespace, "Path_1",0);
}
app.activeDocument.xmpMetadata.rawData = xmp.serialize();
}
Code: Select allmain();
function main(){
if(!documents.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var psNamespace = "http://ns.pathInfo/1.0/";
var psPrefix = "path:";
XMPMeta.registerNamespace(psNamespace, psPrefix);
xmp = new XMPMeta( app.activeDocument.xmpMetadata.rawData );
xmp.deleteProperty(psNamespace, "Path_1");
if(activeDocument.pathItems.length >0){
xmp.setProperty(psNamespace, "Path_1",1);
//amend action to suit
//app.doAction("W-S-Path" , "SWITCH");
}else{
xmp.setProperty(psNamespace, "Path_1",0);
}
app.activeDocument.xmpMetadata.rawData = xmp.serialize();
}