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

Why can't I write a XMPString to a file?

Explorer ,
Dec 25, 2020 Dec 25, 2020
var XMP = new File("~/Desktop/XMP.txt");
XMP.open("e");
XMP.write(app.activeDocument.XMPString);

Why can't I write a XMPString to a file?  The file stays empty. I can print XMPString using alert, so I feel like I am missing something obvious but I don't see it.  Much obliged. 

 

TOPICS
Scripting
514
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

Guide , Dec 25, 2020 Dec 25, 2020
var XMP = new File("~/Desktop/XMP.txt");
XMP.encoding = "UTF-8";
XMP.open("e");
XMP.write(app.activeDocument.XMPString);
XMP.close;
Translate
Adobe
Participant ,
Dec 25, 2020 Dec 25, 2020

Hello if you want to add new xmp to ai doc, you can use serialize method's XMPMeta object and assign the resul to app.activeDocument.XMPString.

 

New XMP is saved with document when you save document.

 

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 ,
Dec 25, 2020 Dec 25, 2020

I think you are missing the file close statement i.e.

XMP.close()

So if app.activeDocument.XMPString has a value then adding close should write the string to the file

-Manan

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 ,
Dec 25, 2020 Dec 25, 2020

Thanks but still fiel stays empty.

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
Guide ,
Dec 25, 2020 Dec 25, 2020
var XMP = new File("~/Desktop/XMP.txt");
XMP.encoding = "UTF-8";
XMP.open("e");
XMP.write(app.activeDocument.XMPString);
XMP.close;
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 ,
Dec 25, 2020 Dec 25, 2020
LATEST

Thsnks, it works!!

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