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

Appending metadata to a file

New Here ,
Jul 20, 2014 Jul 20, 2014

Copy link to clipboard

Copied

Hi,

I found this script to write XMP metadata to an open file, but it does not seem to work for me in Illustrator CC. The error message is "XMP exception: Source and destination XMP must differ".

Is there perhaps an alternative method of writing properties to the XMP fields?

Thanks,

Rich

if( xmpLib == undefined ) {

var xmpLib = new ExternalObject("lib:../../Frameworks/AdobeXMPScript");

app.synchronousMode = true;

}

var docXmp = new XMPMeta(app.activeDocument.XMPString);

var myXmp = docXmp;

myXmp.setProperty(XMPConst.NS_XMP, "CreatorTool", "My Script");

XMPUtils.appendProperties(myXmp, docXmp, XMPConst.APPEND_ALL_PROPERTIES);

var myDocFile = new File(app.activeDocument.fullName);

var docRef = new XMPFile(myDocFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

if (docRef.canPutXMP(docXmp)) { docRef.putXMP(docXmp); }

docRef.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

TOPICS
Scripting

Views

632

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
Adobe
Guru ,
Jul 20, 2014 Jul 20, 2014

Copy link to clipboard

Copied

Is that all your script or just part of it…? Either way it's got a line that is Bridge script…

app.synchronousMode = true; // This ONLY applies to the Bridge App…

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
New Here ,
Jul 21, 2014 Jul 21, 2014

Copy link to clipboard

Copied

It's just part of the script. I want to test if I can write metadata information to the illustrator file. I can then go on target specific fields.

I've removed the Bridge script line, but it's still showing the same error.

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
New Here ,
Jul 22, 2014 Jul 22, 2014

Copy link to clipboard

Copied

LATEST

After much searching I discovered another script that does the trick. The document must be closed and then reopened to view the modifications (took me a while to realise this!)

// load XMP Library

function loadXMPLibrary(){

    if ( !ExternalObject.AdobeXMPScript ){

        try{ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');}

        catch (e){alert('Unable to load the AdobeXMPScript library!'); return false;}

    }

    return true;

}

// select destination file

var myFile = File.openDialog("Select destination file", "Illustrator:*.ai", false);

// check library and file

if(loadXMPLibrary() && myFile != null){

    xmpFile = new XMPFile(myFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

    var myXmp = xmpFile.getXMP();

}

if(myXmp){

    // change Document title to Foo

    myXmp.setProperty(XMPConst.NS_DC, "title", "Foo");

    // put XMP into file

    if (xmpFile.canPutXMP(myXmp)){xmpFile.putXMP(myXmp);}else{alert("Error storing XMP");}

    // close file

    xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

}

// credit to tomaxxi for this script

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