Skip to main content
April 14, 2010
Answered

Extract Preserved File Name

  • April 14, 2010
  • 1 reply
  • 1021 views

I have gone through about 1000 photos and batch renamed them. During this process I made sure that the "Preserve File Name" check box was turned on. My ultimate goal is to somehow take the preserved file name and put it into a normal metadata field (i.e. Keywords). Right now, it exists under the "Raw Data" tab in the file info panel. There is a script that is floating around that will copy the current file name to the "Keywords" metadata. However, I would like to access the Preserved File Name. Anyone have any thoughts on this or somewhere I can look for a script that will do this? I have a feeling this isn't the first time someone has tried to do this, but I have yet to find any scripts or posts that deal with this specifically.

This topic has been closed for replies.
Correct answer Paul Riggott

This should do the job...


#target bridge
addPreserved = {};

addPreserved.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/xap/1.0/mm/";
    var preservedFname = md.PreservedFileName;
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";
    md.Keywords = md.Keywords + ";" + preservedFname;
  }
}

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

var menu = MenuElement.create( "command", "Preserved Filename to Keywords", "at the end of Tools");
  menu.onSelect = addPreserved.execute;
}

1 reply

Paul Riggott
Paul RiggottCorrect answer
Inspiring
April 24, 2010

This should do the job...


#target bridge
addPreserved = {};

addPreserved.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/xap/1.0/mm/";
    var preservedFname = md.PreservedFileName;
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";
    md.Keywords = md.Keywords + ";" + preservedFname;
  }
}

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

var menu = MenuElement.create( "command", "Preserved Filename to Keywords", "at the end of Tools");
  menu.onSelect = addPreserved.execute;
}

April 24, 2010

Paul,

Thanks so much. That did it.