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

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

Explorer ,
Dec 25, 2020 Dec 25, 2020

Copy link to clipboard

Copied

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

Views

322

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 , 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;

Votes

Translate

Translate
Adobe
Participant ,
Dec 25, 2020 Dec 25, 2020

Copy link to clipboard

Copied

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.

 

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

Thanks but still fiel stays empty.

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

Copy link to clipboard

Copied

var XMP = new File("~/Desktop/XMP.txt");
XMP.encoding = "UTF-8";
XMP.open("e");
XMP.write(app.activeDocument.XMPString);
XMP.close;

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

Copy link to clipboard

Copied

LATEST

Thsnks, it works!!

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