Skip to main content
September 23, 2009
Question

edit the description metadata field.

  • September 23, 2009
  • 1 reply
  • 1040 views

Is it possible to edit the 'description' field through a script.  I've been trying off and on all day and coming up dry. here is what i have now thanks to some script i've found from John Beardsworth (thanks, btw!!) that i managed to narrow to my needs...

#target bridge
if ( app.name == "bridge"  && app.version[0] == '3' )
{


// Create main menu item
   
    var menu = new MenuElement( "menu", "Filename to Metadata cart", "at the end of Tools", "g2mMenu");
    var g2tCommand =  new MenuElement("command", "click here", "at the end of g2mMenu");
//-----------------------------------------------------------------------
//Submenu for filename to iptc title
    g2tCommand.onSelect = function(m)
        {
        var getFolderChildren = true ;
        var filesOnly = true ;
        var thumbs = app.document.selections;
        for ( var i = 0; i < thumbs.length; i++ )
        { var thumb = thumbs;
           var md = thumb.synchronousMetadata;
           md.namespace ="http://purl.org/dc/elements/1.1//";
           md.Description= "hello World";
        }
           Window.alert ("Done " + i + " records");
        };

//closing brace
}

I simply cannot get it to change the info in the description field.  It even willl give me the alert saying it did  it and nothing will be there.  this works fine for Title and Headline, but not description... any ideas?

obivously this is a simpler version of what i actually want to write into the description field, otherwise i wouldn't need a script.  But if i can get this to work, i can get my real needs to work as well.

thansk.

This topic has been closed for replies.

1 reply

dfranzen_camera_raw
Adobe Employee
Adobe Employee
September 25, 2009

I think your main problem is that you are using the wrong property name. Try "description" and not "Description." XMP property names are case sensative.

The following script works for me:

#target bridge


// Where is this script?

var curFolder = new File( $.fileName ).parent;


// Make a simple JPEG file here for the test

var somePixels = new BitmapData( 300, 200);

var jpgFile = new File( curFolder.fsName + "/test.jpg");

somePixels.exportTo( jpgFile, 100, true );


// Make a thumbnail

var thumb = new Thumbnail( jpgFile );


// Get the Metadata

var md = thumb.synchronousMetadata;


// set the namespace

app.synchronousMode = true;

md.namespace = "http://purl.org/dc/elements/1.1/";

// set the property

md.description = "Testing 1,2,3";


// Make sure the Bridge UI sees the change

thumb.core.metadata.cacheData.status = "bad";

If I change my script to use "Description" then the script sets a new, bogus property "dc:Description" in the XMP.
I recommend always keeping a copy of Part 2 of the XMP Specification handy when writing any scripts that modify metadata. Double check the spec for the correct namespace URIs and property names. Get the spec here: http://www.adobe.com/devnet/xmp/
-David