script to insert file name into IPTC field of same file

General Discussion of Scripting for Adobe Bridge

Moderators: Tom, Kukurykus

edrob

script to insert file name into IPTC field of same file

Post by edrob »

Is there a ready made script for Bridge that can batch process a folder and insert the file's name into a IPTC field within that file?
Thanks,
Ed R.
Mike Hale

script to insert file name into IPTC field of same file

Post by Mike Hale »

You don't need a script. Use Bridge's batch rename. You can set the name options so it will use the same name if you don't want them renamed and if you check 'Preserve current filename...' the name will be added to the Metadata. With Raw files the XMP is writted to a sidecar.

Mike
edrob

script to insert file name into IPTC field of same file

Post by edrob »

Mike, thanks for the quick reply.
The photo agency I work with wants the original file name in the "Source" field. I did confirm that a batch rename will embed the file name as you stated. Unfortunately it is buried in the "advanced" section. So I am still looking for a way to automate inserting the file name into the "Source" field.
Ed R.
Mike Hale

script to insert file name into IPTC field of same file

Post by Mike Hale »

Sorry, I missed where you wanted it stored when I read your post. Put the script below in your startup scripts folder, restart Bridge. In the tool menu there will be a new menu item. Select the files you want to update and run the script, ie it only works with selected files

Code: Select all#target bridge

addNametoMeta = {};

addNametoMeta.execute = function(){    
  var sels = app.document.selections;   
  for (var i = 0; i < sels.length; i++){

var md = sels.synchronousMetadata;
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";
    md.Source = sels.name;
  }
}

// this script only works in bridge
if (BridgeTalk.appName == "bridge"){

  var menu = MenuElement.create( "command", "Save Filename in Metadata", "at the end of Tools");
  menu.onSelect = addNametoMeta.execute;
}