Skip to main content
Participating Frequently
February 23, 2016
Answered

Copying filename to IPTC description - camera raw formats

  • February 23, 2016
  • 2 replies
  • 2107 views

This question has been asked previously in Bridge forums but not fully answered for CC and raw files.

I'd like to run a script from Bridge CC that will append the filename (minus extension) into the Description field of the IPTC metadata. It needs to work with multiple camera raw files (e.g. .ARW, .CR2). Previous suggestions worked with TIFs and DNGs but not proprietary camera raw formats.

Since characters '/' and ':' aren't permitted or recommended, it would be useful if these could be added by converting '*' and '=' from the filename.

For example,

Filename 1234.ARW should append as 1234

Filename 12*34.ARW should append as 12/34

Filename 12=34.ARW should append as 12:34

The description field may already contain some text, hence the need to append to this rather than replace.

If anybody could help with this, I'd be very grateful.

This topic has been closed for replies.
Correct answer SuperMerlin

Ok, please try this.

#target bridge;

   if( BridgeTalk.appName == "bridge" ) {

f2Desc = new MenuElement("command", "Filename to Description", "at the end of Tools");

}

f2Desc.onSelect = function () {

var sels = app.document.selections;

for(var a in sels){

var thumb = sels;

var Name = decodeURI(thumb.spec.name).replace(/\.[^\.]+$/, '');

Name =Name.replace(/\=/g,':').replace(/&/g,'/');

md = thumb.synchronousMetadata;

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

var Caption = md.description ? md.description[0] : "";

md.description='';

if(Caption != undefined){

    md.description = Caption + " " + Name;

    }else{

md.description = Name;

}

}

app.document.chooseMenuItem('PurgeCache');

};

2 replies

Stephen Marsh
Community Expert
Community Expert
August 9, 2016

I have not tested, however it is my understanding that Adobe do not allow editing of the raw file, even if it is just adding metadata (DNG being the exception). The metadata would be applied to the ACR database or XMP sidecar files. The venerable ExifTool will directly write metadata into a proprietary raw file (rewriting the entire raw file).

SuperMerlin
Inspiring
August 9, 2016

That's true, but writing to a normal or a raw can use the same code if written in a certain way.

Here is an example of code to be run from ExtendScript Toolkit with a file selected in Bridge.

#target bridge;

item = app.document.selections[0];

md =item.synchronousMetadata;

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

md.title = "My Title";

md.namespace = "http://ns.adobe.com/photoshop/1.0/";

md.Author = ''; //remove data

md.Author = "My name goes here"; //add new data

This should work on all file types that support metadata.

With a raw file the xmp file will be auto generated if it didn't exist.

Stephen Marsh
Community Expert
Community Expert
August 9, 2016

Just wanted the OP to know the difference, not knowing the expectation or how literal the topic title was intended to be.

SuperMerlin
Inspiring
February 23, 2016

This script should be easy to write, BUT an asterisk it not allowed in a files name.

Is there an alternative you could use as a replacement?

Participating Frequently
February 23, 2016

Thanks - I thought an asterisk was allowed! Anyway, I could use anything else allowed - how about '&'?

SuperMerlin
SuperMerlinCorrect answer
Inspiring
February 23, 2016

Ok, please try this.

#target bridge;

   if( BridgeTalk.appName == "bridge" ) {

f2Desc = new MenuElement("command", "Filename to Description", "at the end of Tools");

}

f2Desc.onSelect = function () {

var sels = app.document.selections;

for(var a in sels){

var thumb = sels;

var Name = decodeURI(thumb.spec.name).replace(/\.[^\.]+$/, '');

Name =Name.replace(/\=/g,':').replace(/&/g,'/');

md = thumb.synchronousMetadata;

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

var Caption = md.description ? md.description[0] : "";

md.description='';

if(Caption != undefined){

    md.description = Caption + " " + Name;

    }else{

md.description = Name;

}

}

app.document.chooseMenuItem('PurgeCache');

};