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

UXP/Scripting Solution for Importing and Exporting XMP Metadata

New Here ,
Dec 11, 2024 Dec 11, 2024

I know that there is a manual solution to do this via the File => File Info menu. See images below.

The export option saves an XMP file containing all of the file metadata. 

On a new file, you can import the saved file and select different options about how to treat existing data and what is contained in the file. 

I would like to create a script that performs these actions in a controlled and repeatable way for users.

I am having trouble identifying the relevant UXP objects that would allow me to do this. Has anyone had success with this sort of import and export behavior?

Michael38639541dcyl_0-1733944920351.png

Michael38639541dcyl_1-1733949802044.png

 

 

TOPICS
Import and export , UXP Scripting
982
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

Engaged , Dec 11, 2024 Dec 11, 2024

document.metadataPreference.replace() or document.metadataPreference.append().

Translate
Engaged ,
Dec 11, 2024 Dec 11, 2024

It looks like document.metadataPreference.

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 11, 2024 Dec 11, 2024

Thanks!

I was looking at this object independently and saw a save option, but wasn't sure whether this was the same action as exporting via the GUI. 

I was able to use the document.metadataPreference.save option to save to an XMP file. I do not see a method on this object for importing, though. 

Curious if other folks have found a way to do this.

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
Engaged ,
Dec 11, 2024 Dec 11, 2024

document.metadataPreference.replace() or document.metadataPreference.append().

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 11, 2024 Dec 11, 2024

Just found the same thing independently. Thanks for the confirmation!

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
Explorer ,
Aug 04, 2025 Aug 04, 2025

How to register custome namespace and show fileInfo panel ?
I have use metadataPreferences

 const getXmpData = () => {
    var doc = app.activeDocument;

    var xmpStr = doc.metadataPreferences.metadata;
    if (!xmpStr || xmpStr.length === 0) {
      console.log("No metadata found.");
      return;
    }

    var xmp = new XMPMeta(xmpStr);
    var customNS = "http://your.custom.namespace/";
    var prefix = "fileInfo";

    XMPMeta.registerNamespace(customNS, prefix);

    var prop = xmp.getProperty(customNS, "rawData");

    if (prop) {
      console.log("Custom metadata:\n" + prop.value);
    } else {
      console.log("Custom metadata not found.");
    }
  };
indesign uxp there more confusion what I have use xmpFIle is work when i external link and localFileSystem use then show fileInfo panel newly inserted metadata 
but I want to add customdata with use activeDocument registernamespace and set,get so metaPreferences is perfect for my use case ?
I need help 
Thank you,
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
Explorer ,
Aug 04, 2025 Aug 04, 2025

but this code is not working is there any method name mismatch ?

 

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
Community Expert ,
Aug 04, 2025 Aug 04, 2025
LATEST
quote

but this code is not working is there any method name mismatch ?

 

By @ashwin_0502

 

Are you sure you're not running into the very same issue discussed in your initial post here:

https://forums.creativeclouddeveloper.com/t/is-there-any-manifest-permission-for-activedocument-file...

 

That is, that you're still trying to modify an open document using an external library?

 

(I'm not a UXP expert, so that's just my guess based on my understanding of the answer to your initial question).

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