Bridge Script to Remove Photoshop DocumentAncestors Metadata
Bloated files that contain “excess” Photoshop DocumentAncestors metadata have been causing a few users some grief (65mb down to 110kb)!
Photoshop saving issue (FILES TOO LARGE)
There is a script for Photoshop to remove this metadata, however as this requires an open/save it is not great for files that contain lossy compression. Bridge is the obvious place to remove this metadata. I have hacked a different script to remove this DocumentAncestor metadata.
I don’t understand why Bridge requires a 2 step process! All this time I thought that the code was bad, when it was “working fine”.
Step 1: Run the Bridge script to remove DocumentAncestors metadata (the file size does not change, when it “should”)
Step 2: Apply a secondary metadata change in Bridge, such as adding/removing a temporary keyword, or rotating clockwise and then rotating back counterclockwise again to “force the image to reset”
The second step for whatever reason will force the file to update and take into account the removal of the DocumentAncestors metadata and then applies the file size reduction!
The code:
// https://forums.adobe.com/thread/290238
// https://forums.adobe.com/thread/1880847
// https://forums.adobe.com/thread/2340460
#target bridge // let EntendScript know what app the script is for
clearDocumentAncestors = {};// create an object
clearDocumentAncestors.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.synchronousMetadata;// get the metadata for the file
md.namespace = "http://ns.adobe.com/photoshop/1.0/";// set the namespace
md.DocumentAncestors = " ";//set the porperty
}
}
// this script only works in bridge
if (BridgeTalk.appName == "bridge"){
//creage the munuItem
var menu = MenuElement.create( "command", "Clear DocumentAncestors in metadata", "at the end of Tools");
menu.onSelect = clearDocumentAncestors.execute;
}

