What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Can the "Description" metadata fields be deleted with a Photoshop Script?

Chris S

New Member
Any gurus here with Photoshop scripting knowledge that can help me clear out just the 4 metadata fields below with a Photoshop script?
  • [EXIF] ImageDescription
  • [XMP-dc] Description
  • [IPTC] Caption-Abstract
  • [XMP-Photoshop] DocumentAncestors

First, let me say that I know this can easily be done with the ExifTool code below:
exiftool -m -overwrite_original_in_place -EXIF:ImageDescription= -XMP:dc:Description= -IPTC:Caption-Abstract= [DIR]

While this works great for me, I would like to do this same thing with a Photoshop script, if possible, since all of the sites that will be using this don't have ExifTool. Also, with a script I can ensure it automatically gets checked/done when a file is opened/saved in Photoshop.

Below is the .jsx script I have so far:
function deleteUnwantedMetadata() {
    whatApp = String(app.name);
    if(whatApp.search("Photoshop") > 0)  {
        if(!documents.length) {
        alert("No open documents. Open a file to run script.")
        if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
        var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);
           xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
           if (xmp.doesArrayItemExist(XMPConst.NS_DC, "description", 1))
                xmp.deleteArrayItem(XMPConst.NS_DC, "description", 1);
            app.activeDocument.xmpMetadata.rawData = xmp.serialize();

This script is invoked with the Photoshop Scripts Events Manager on Document Open.


:) TIFF: Works as desired... all 4 fields are cleared.

:cry: PSD, PSB and JPG: 3 of the 4 fields ([EXIF]ImageDescription, [IPTC]Caption-Abstract and [XMP-Photoshop]DocumentAncestors) are cleared as I'd like. However, for these image formats, the data that was once in [EXIF]ImageDescription is now in [XMP-dc]Description.

:unsure: I noticed that if I open the PSD, PSB and JPG files a second time and run through the script, then everything gets cleared out on these files as well.

If I add xmp.setLocalizedText(XMPConst.NS_DC, "description", null, "x-default", " "); below xmp.deleteArrayItem(XMPConst.NS_DC, "description", 1);. above, this will at least clear everything out and just include a space for the field, but would rather have the filed empty if possible (null doesn't appear to work here).


I believe this has something to do with how the [EXIF]ImageDescription and [XMP-dc]Description work together, but not sure how to resolve. It would appear this script is clearing the [XMP-dc]Description, pulling the contents of the [EXIF]ImageDescription into it, which then clears the [EXIF]ImageDescription. Since [EXIF]ImageDescription was cleared by the script the first time, running it a second time puts that cleared value of the XMP-dc:Description into itself, thereby freeing all of them up.

If my assumptions are correct, this leaves a few questions...


1) Is there a way to amend the code to clear out the [EXIF]ImageDescription first? If so, how?

2) If not, any suggestions how I could modify the code to run only once to ensure the PSD/PSB/JPG is fixed the first time? I tried the two things below that didn't work:
- Called the function from within the script twice
- Added the script to 2 events (On Open & On Close)

PS: I don't want to delete all metadata, just these fields.


Test image and .jsx script are attached for reference.

Posted similar question to PS-Scripts, Adobe Support Community and Stack Overflow... no solutions yet.

I found this post on Exiftool's forum that was helpful in understanding the interplay of the description fields.


  • Sample_Script_Test_Images.zip
    74.1 KB · Views: 3
Adobe's XMP/EXIF implementation doesn't work with all metadata fields. Its FAR easier to use EXIFTool for this. I have written a numberŕof utility scripts but finally had to write an integration for Bridge/Photoshop and EXIFTool to actually deal with metadata the way I needed.