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

how can i set a metadata with a variable

Community Beginner ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Hello together,

 

i need help, I want to set Metadata with a variable ITPC Scene Code.

 

I have this code, but I don't know to get the variable in the code.

#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Add Web Scene Code to Scene Code", "at the end of Tools");
}
FT.onSelect = function () {
AddWebSceneToSceneCode();
}

function AddWebSceneToSceneCode(){
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new
ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
//var WebSceneCode = decodeURI(selectedFile.name)//.replace(/\.[^\.]+$/, '')//([0-9/[-]*/.jpg/]*) nur name
var WebSceneCode="12345"
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN,
XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
myXmp.deleteProperty(NS_IPTC_CORE, "Iptc4xmpCore:Scene");
myXmp.appendArrayItem(NS_IPTC_CORE, "Iptc4xmpCore:Scene", WebSceneCode, 0,
XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XNS_IPTC_CORE, "Iptc4xmpCore:Scene"[1]",
"http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}

 

How I get the var WebSceneCode="12345" in the code, for working.

 

Thank you for your help.

 

Jörn

TOPICS
How to , Metadata , Scripting

Views

112

Likes

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
Community Expert ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

LATEST

This script has the same problem as your other one... Iptc4xmpCore:Scene is a bag array, not langAlt.

What indicates that this script is langAlt?

XMPConst.ALIAS_TO_ALT_TEXT

 

myXmp.setQualifier(XNS_IPTC_CORE, "Iptc4xmpCore:Scene"[1]",
"http://www.w3.org/XML/1998/namespace", "lang", "x-default");

 

Also, the namespace is wrong. NS_IPTC_CORE

It should be XMPConst.NS_IPTC_CORE

 

#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Add Web Scene Code to Scene Code", "at the end of Tools");
}
FT.onSelect = function () {
AddWebSceneToSceneCode();
}

function AddWebSceneToSceneCode(){
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
//var WebSceneCode = decodeURI(selectedFile.name)//.replace(/\.[^\.]+$/, '')//([0-9/[-]*/.jpg/]*) nur name
var WebSceneCode = "12345"
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
myXmp.deleteProperty(XMPConst.NS_IPTC_CORE, "Iptc4xmpCore:Scene");
myXmp.appendArrayItem(XMPConst.NS_IPTC_CORE, "Iptc4xmpCore:Scene", WebSceneCode, 0, XMPConst.ARRAY_IS_UNORDERED);
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}

 

Likes

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