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

Add new MetaData in the PSD document using script

Contributor ,
Mar 28, 2022 Mar 28, 2022

Copy link to clipboard

Copied

Hi All,

The below code I have found for Indesign to add meta data from the JSON, likewise I looking for photoshop psd files is it possible? Please share your thoughts.

 

var md = app.activeDocument.metadataPreferences;
var ns = "http://ns.adobe.com/xap/1.0/";
var p, v;

//the json object
var o = {"Name":"John Doe","id":"1234","Address":"Main Street"}
var props = o.reflect.properties;

for (var i = 0; i < props.length-4; i++){
    p = props[i].name
    v = o[props[i]]
    md.setProperty(ns, p, v)
};   

 

TOPICS
Actions and scripting , macOS

Views

354

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

Guide , Mar 28, 2022 Mar 28, 2022
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

var md =  new XMPMeta(activeDocument.xmpMetadata.rawData)
var ns = "http://ns.adobe.com/xap/1.0/";
var p, v;

//the json object
var o = {"Name":"John Doe","id":"1234","Address":"Main Street"}
var props = o.reflect.properties;

for (var i = 0; i < props.length-4; i++){
    p = props[i].name
    v = o[props[i]]
    md.setProperty(ns, p, v)
};   

activeDocument.xmpMetadata.rawData = md.serialize()

2022-03-28_14-34-28.png

Votes

Translate

Translate
Adobe
Guide ,
Mar 28, 2022 Mar 28, 2022

Copy link to clipboard

Copied

LATEST
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

var md =  new XMPMeta(activeDocument.xmpMetadata.rawData)
var ns = "http://ns.adobe.com/xap/1.0/";
var p, v;

//the json object
var o = {"Name":"John Doe","id":"1234","Address":"Main Street"}
var props = o.reflect.properties;

for (var i = 0; i < props.length-4; i++){
    p = props[i].name
    v = o[props[i]]
    md.setProperty(ns, p, v)
};   

activeDocument.xmpMetadata.rawData = md.serialize()

2022-03-28_14-34-28.png

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