Copy link to clipboard
Copied
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.
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Thanks - I thought an asterisk was allowed! Anyway, I could use anything else allowed - how about '&'?
Copy link to clipboard
Copied
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');
};
Copy link to clipboard
Copied
Thanks! It works well. Only problem is that after running the script, the new metadata only shows up if I quit and restart Bridge. I can live with this though! Very useful anyway. Many thanks for your help!
Copy link to clipboard
Copied
You can select the files, right mouse click then purge cache for selection. This will then update the files without restarting Bridge.
Copy link to clipboard
Copied
That works perfectly now, thanks again!
Copy link to clipboard
Copied
Hi, I've been trying to modify this script to add the filename into the 'keywords' field instead. Replacing 'description' with 'keywords' or 'subject' doesn't seem to work - any suggestions please?
Copy link to clipboard
Copied
Have a look at this. Copy Filename to IPTC Keywords
Copy link to clipboard
Copied
That's great, many thanks again!
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Just wanted the OP to know the difference, not knowing the expectation or how literal the topic title was intended to be.