Skip to main content
Participant
January 23, 2020
Question

Batch Keyword Delete

  • January 23, 2020
  • 2 replies
  • 1363 views

I imported some photos that have keywords in the Metadata. Is there a way to batch delete all keywords from a selection of photographs. I don't want to open each of the hundreds of photos to delete the keywords in the metadata.

Thanks

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
January 23, 2020

If you wish to remove all keywords from all selected images, you could use a script:

 

 

 

//forums.adobe.com/thread/290238
//forums.adobe.com/message/1115698#1115698
#target bridge
clearSubKey = {};// create an object
clearSubKey.execute = function(){// create a method for that object
  var sels = app.document.selections;// store the array of selected files
  for (var i = 0; i < sels.length; i++){//loop though that array
    var md = sels[i].synchronousMetadata;// get the metadata for the file
     md.namespace = "http://ns.adobe.com/photoshop/1.0/";// set the namespace
     md.Keywords = "";//set the porperty
  }
}
// this script only works in bridge
if (BridgeTalk.appName == "bridge"){
  //creage the munuItem
  var menu = MenuElement.create( "command", "Clear Subject Keywords Metadata", "at the end of Tools");
  menu.onSelect = clearSubKey.execute;
}

 

 

 

This modified version of the previous script will also remove all Adobe Lightroom hierarchicalSubject keywords:

 

 

 

//forums.adobe.com/thread/290238
//forums.adobe.com/message/1115698#1115698
#target bridge
clearLHS = {};// create an object
clearLHS.execute = function(){// create a method for that object
  var sels = app.document.selections;// store the array of selected files
  for (var i = 0; i < sels.length; i++){//loop though that array
    var md = sels[i].synchronousMetadata;// get the metadata for the file
     md.namespace = "http://ns.adobe.com/lightroom/1.0/","hierarchicalSubject";// set the namespace
     md.hierarchicalSubject = "";//set the porperty
  }
}
// this script only works in bridge
if (BridgeTalk.appName == "bridge"){
  //creage the munuItem
  var menu = MenuElement.create( "command", "Clear Lr hierarchicalSubject Keywords Metadata", "at the end of Tools");
  menu.onSelect = clearLHS.execute;
}

 

 

 

P.S. I have not combined the two scripts into one, which would be the next logical step (editing the code to combine the two scripts is proving to be harder than expected)...

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Legend
January 24, 2020

My Keyword Optimizer deletes keywords before rewriting them. However, they are in dc:subject, I am not working with the Photoshop namespace. There is also a MicrosoftPhoto namespace that can store keywords.

 

 

var kwList = app.document.selections;

var i = 0;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
for(i = 0; i < kwList.length; i++){ //loop through selected files
if(kwList[i].hasMetadata){ //only process files with metadata

var md = kwList[i].synchronousMetadata;
var xmp = new XMPMeta(md.serialize());
//delete old keywords in both namespaces
XMPUtils.removeProperties(xmp, XMPConst.NS_DC, 'subject', XMPConst.REMOVE_ALL_PROPERTIES);
XMPUtils.removeProperties(xmp, 'http://ns.adobe.com/lightroom/1.0/', 'hierarchicalSubject', XMPConst.REMOVE_ALL_PROPERTIES);

}

}

Legend
January 23, 2020

Select all and use the Keyword panel to uncheck the keywords you want removed.