Skip to main content
Inspiring
June 3, 2013
Answered

Read metadata for a file without Photoshop or Bridge

  • June 3, 2013
  • 3 replies
  • 2983 views

Hi

Suppose I have a file in desktop called "test.jpg". So I create this variable:

var myFile = new File ("~/Desktop/test.jpg");

This file has some keywords and instructions I need to read. And if the reading process finds the correct keyword, then it copies the file to the appropriated folder. Well, in resume, I could do everything directlly using #target estoolkit. I´d not like to involve (opening) Photoshop or Bridge.

Is it possible to read the metadata of a file without targetting Bridge or Photoshop? Reading the reference I did not find any method or property for this, expect for the metadata library. BUT

If I try to load the metadata library using:

if (ExternalObject.AdobeXMPScript == undefined) {

        ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

    };

then it sure will returns an error file or folder does not exists..

Any idea how I could proceed to load this library and read the metadata of a file directlly?

Thank you very much

Best Regards

Gustavo.

This topic has been closed for replies.
Correct answer Michael_L_Hale

The documentation on working with XMP is in the JavaScript Tools Guide.

var test = new File("~/Desktop/Test.jpg");

var xmpf = new XMPFile( test.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ );

var xmp = xmpf.getXMP();

xmpf.closeFile();

var modDate = xmp.getProperty(XMPConst.NS_XMP, "ModifyDate").toString();

alert(modDate);

3 replies

Inspiring
June 3, 2013

Exiftool supports reading/writing metadata as well as copying/moving files using the command line. I think whether you use it as part of an ESTK script or standalone bat/bash file would depend on if the keywords used changes often. I don't know if ExifTool changes the modified date when moving files based on metadata tags.

Inspiring
June 4, 2013

Hi friends

Thank you very much for your inputs. Muppet....what do you mean when you write The modified date gets bumped and can be a PITA? What means "PITA"?

So, if it´s impossible to invoke [directly] the default library without targetting Bridge or Photoshop...I´ll simplify the things and use Bridge to house the script. No problem.

So, look at what I´m doing:

#target bridge

if (ExternalObject.AdobeXMPScript == undefined) {

        ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

};

var test = new File ("~/Desktop/Test.jpg");

var xmp = test.metadata;

alert(xmp);

...But, the alert in Adobe Bridge is returning nothing (""). And I know this image exists and it has metadata.

I remember to use metadata for reading the currently selected image in Content panel of Bridge (and it worked), but never tried direrctly declaring a file and reading this way.

Am I missing anything obvious?

Thank you very much

Gustavo.


Message was edited by: Gustavo Del Vechio

Inspiring
June 4, 2013

Gustavo… The Bridge app has a built-in method to move files about… This does in fact move the original to a new location…

The ESTK file object has NO move method… What you can do is copy the file to new location and remove the original…

But a NEW file is created and the data put into this… If like me you put these files in other documents…

Links in AI or ID then you will be constantly having to update all the modified links…

You may well be neadlessly backing it all up again too…

PITA == pain in the ar$e

Inspiring
June 3, 2013

I probably would not use ExtendScript to do this… I would avoid the file object's copy() method as it creates a new file…

The modified date gets bumped and can be a PITA… Using Abobe's ESTK only Bridge can move files to location without doing this…

You would probably be better served using something else your system supports… ExifTool is available in a few flavors…

Paul Riggott
Inspiring
June 3, 2013

External libraries require you have Photoshop or Bridge as the target so no you can't do it direct in ExtendScript.

The only other way would be to use ExifTool and read/write the details to/from a file, then you could use ExtendScript only, but it would be much slower.