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

XMP : Remove a nod from InDesign metadata

New Here ,
Dec 03, 2019 Dec 03, 2019

Hello,

Can anyone tell me how to delete a node from the Indesign metadatas?

var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.deleteProperty(EspaceXMP,"TEST[1]"); //doesn't work (XMPs.deleteProperty is not a function)
XMPs.removeProperty(EspaceXMP,"TEST[1]"); //doesn't work (XMPs.deleteProperty is not a function)

Thank you.

TOPICS
How to , Scripting
848
Translate
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

Advocate , Dec 03, 2019 Dec 03, 2019

Try this code for you reference:

 

var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"","");

//// To remove the property, pass an empty string.

 

Best

Sunil

Translate
Community Expert ,
Dec 03, 2019 Dec 03, 2019

You can't. metadataPreferences is not "XML", it is part of the document model: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#MetadataPreference.html 

 

If you are trying to clear a property, find its DOM name and type and set it to [], "" or 0.

Translate
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
Advocate ,
Dec 03, 2019 Dec 03, 2019

Try this code for you reference:

 

var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"","");

//// To remove the property, pass an empty string.

 

Best

Sunil

Translate
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
New Here ,
Dec 03, 2019 Dec 03, 2019
LATEST

Thank you Sunil, You're solution almost works to remove the all property :

var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"TEST","");

But you also give me the way to remove only one nod in the property :

var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"TEST[2]",""); //remove the second nod of TEST property.

 Thanks a lot

Translate
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