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

Exporting metadata to an XML file

New Here ,
Sep 17, 2007 Sep 17, 2007
Hi!

I'm trying to write a script that exports the metadata (camera info and photo description) from all the images in a folder to an XML file and then saves it to the same folder.
My knowledge of JavaScript is a little rusty and i would need some help. I started reading through the Bridge Scripting Guide, but i gave up...
If someone could help me to get started with the script, i would really appreciate it.

Thank you

Balint
TOPICS
Scripting
1.3K
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 ,
Sep 18, 2007 Sep 18, 2007
This will get you started. It extracts properties from the EXIF and XMP Basic schemas from a selected thumbnail and writes the metadata to the JS console and to a file. Open the script in the ESTK and run it against Bridge with a selection made.

The info you need to modify this script to suit your needs is in the JavaScript Tools guide which you can get with the Bridge SDK from http://www.adobe.com/devnet/bridge/

// Load the XMP Script library
if( xmpLib == undefined )
{
if( Folder.fs == "Windows" )
{
var pathToLib = Folder.startup.fsName + "/AdobeXMPScript.dll";
}
else
{
var pathToLib = Folder.startup.fsName + "/AdobeXMPScript.framework";
}

var libfile = new File( pathToLib );
var xmpLib = new ExternalObject("lib:" + pathToLib );
}

// Get a selected thumbnail
var thumb = app.document.selections[0];
if(thumb.hasMetadata)
{
// Get the selected file
var selectedFile = thumb.spec;

// Create an XMPFile - this allows you to extract the XMP data
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);

// The XMP object from the selected thumb
var thumbXMP = myXmpFile.getXMP();

// An empty XMP object
var myXMP = new XMPMeta();

// Create an iterator that will only visit EXIF properties
var iter = thumbXMP.iterator(0, XMPConst.NS_EXIF);
while((prop = iter.next()) != null)
{
if(prop.path != "")
{
//$.writeln(prop.namespace + " " + prop.path + " " + prop.value, prop.options);
myXMP.setProperty(prop.namespace, prop.path, prop.value, prop.options);
}
}

// Create an iterator that will only visit XMP Basic properties
iter = thumbXMP.iterator(0, XMPConst.NS_XMP);
while((prop = iter.next()) != null)
{
if(prop.path != "")
{
//$.writeln(prop.namespace + " " + prop.path + " " + prop.value, prop.options);
myXMP.setProperty(prop.namespace, prop.path, prop.value, prop.options);
}
}

var myXMPPacket = myXMP.serialize (XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER);

$.writeln(updatedPacket);

var outFile = File(thumb.spec.fsName + ".xml");
outFile.open("w");
outFile.write(myXMPPacket);
outFile.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
New Here ,
Sep 18, 2007 Sep 18, 2007
Chanandler,

Thank you for the fast reply, the code you sent works great!
I just had to comment out line 57: $.writeln(updatedPacket);

I think i should be able to go from here, i want make it recursive for all the files in the folder and select only a couple of the entries in the metadata.
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 ,
Sep 18, 2007 Sep 18, 2007
Cool - glad to help :)

Have a look through the JavaScript Tools Guide though because there is more than one way to do this. If you have a lot of files then above code may not be the best solution.

Cheers.
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 ,
Sep 18, 2007 Sep 18, 2007
There should be about 40 images per folder maximum.

I also just found a "bridge to xml for adobe spry" script at imagic, here:
http://imagicdigital.wordpress.com/2006/07/12/export-xml-from-bridge-for-spry-gallery-ii/

It seems like another simple solution, i just copy the link here for other people for future reference...
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 ,
Sep 19, 2007 Sep 19, 2007
I have a simple script now working, but i am having problems, wherever the metadata tags use accented latin characters (áéüö, etc.).

I managed to save the resulting file in UTF-16 encoding, and if i do a test f.write("éáüöő"), the characters are preserved correctly.
However all the special characters in the meta tags are broken.
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 ,
Nov 30, 2008 Nov 30, 2008
LATEST
No solution et?

Good Luck.
______
My Si tes
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