Script to Remove "Description" tag/metadata in PSD/PSB?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

Chris S
Posts: 4
Joined: Sun Feb 05, 2023 1:12 am

Script to Remove "Description" tag/metadata in PSD/PSB?

Post by Chris S »

I want to get rid of the description listed in the "Get Info" field of the MacOS Finder using a Photoshop script.

Using EXIFTOOL I found that the data I'm looking to remove is in 3 tags:
  • [EXIF:IFD0] ImageDescription
  • [XMP:XMP-dc] Description
  • [IPTC] Caption-Abstract

EXIFTOOL can remove with the code below:

Code: Select all

exiftool -m -overwrite_original_in_place -EXIF:ImageDescription= -XMP-dc:Description= -IPTC:Caption-Abstract= FILE
While that works well, I would like to do it via a script for the flexibility (having other sites do it without having to install EXIFTOOL).

I've got it partially right... when I try to run the script below via the Photoshop Script Events "On Document Open" to remove the data, it works properly on a TIF and PNG (removing from all 3 fields), but I have to run it through twice (Open-Save-Close-Open-Save) to get it removed on a corresponding PSD, PSB or JPG.

If it helps diagnose, I see in EXIFTOOL this data is reported under EXIF:ImageDescription, XMP-dc:Description and IPTC:caption-abstract. To remove via EXIFTOOL, I had to remove all 3 per the code above.

Using the Photoshop script below:
* Before Running: the same data shows up under IFD0:ImageDescription, XMP-dc:Description and IPTC:caption-abstract
* After First Time: data still shows up under XMP-dc:Description (only for PSD/PSB/JPG; it's cleared for TIF/PNG)
* After Running Second Time: description and data is removed as I'd like on all formats

How could I fix this to completely remove the description field on the PSB/PSD/JPGs on the first try?

Code: Select all

function removeMetadata() {
    whatApp = String(app.name);
    if(whatApp.search("Photoshop") > 0)  { 
         if(!documents.length) {
        alert("There are no open documents. Please open a file to run this script.")
        return;
        }
        if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
        var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);
            if (xmp.doesArrayItemExist(XMPConst.NS_DC, "description", 1))
            {
                xmp.deleteArrayItem(XMPConst.NS_DC, "description", 1);
            }
            app.activeDocument.xmpMetadata.rawData = xmp.serialize();

            debugger
         }
}
removeMetadata();
Sample image file and script attached for reference.
Attachments
Remove_Metadata_Test.zip
(15.32 KiB) Downloaded 355 times
Last edited by Chris S on Thu Feb 16, 2023 9:17 pm, edited 1 time in total.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

ambrelangelidou
Posts: 1
Joined: Sat Feb 11, 2023 12:11 pm

Re: Script to Remove "Description" tag/metadata in PSD/PSB?

Post by ambrelangelidou »

Hi, I can't help you but I have an alternative question xD.

Are you able to modify the metadata of your PSD files as you wish? Or can you just delete them?


---------
Improve your scrabble skills https://www.tricher-scrabble.fr
Last edited by ambrelangelidou on Mon Feb 27, 2023 3:18 pm, edited 1 time in total.
Chris S
Posts: 4
Joined: Sun Feb 05, 2023 1:12 am

Re: Script to Remove "Description" tag/metadata in PSD/PSB?

Post by Chris S »

ambrelangelidou wrote: Sat Feb 11, 2023 12:15 pm Are you able to modify the metadata of your PSD files as you wish? Or can you just delete them?
Depending on the metadata, yes. It could be done multiple ways depending on the need/ease (i.e., Adobe Bridge, with scripts, Exiftool, etc.).
Chris S
Posts: 4
Joined: Sun Feb 05, 2023 1:12 am

Re: Script to Remove "Description" tag/metadata in PSD/PSB?

Post by Chris S »

Thank you @Kukurykus... that was my post to the same topic. :D

I actually have a more recent, more detailed one at the link below with my latest findings:
Can the "Description" metadata fields be deleted with a Photoshop Script?

Was hoping perhaps you may have some wisdom to share on this based on your related/similar posts?
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Script to Remove "Description" tag/metadata in PSD/PSB?

Post by Kukurykus »

If you haven't done that yet you may try to search for it in one of other threads: [EXIF] ImageDescription scripting
xeniate
Posts: 1
Joined: Thu Feb 22, 2024 2:46 am

Re: Script to Remove "Description" tag/metadata in PSD/PSB?

Post by xeniate »

Chris S wrote: Tue Feb 21, 2023 2:32 am Thank you @Kukurykus... that was my post to the same topic. :D

I actually have a more recent, more detailed one at the link below with my latest findings:
Geometry Dash

Was hoping perhaps you may have some wisdom to share on this based on your related/similar posts?
In the realm of digital design, efficiency is paramount. As designers, we often find ourselves juggling numerous files, each containing a plethora of metadata that can sometimes be more of a hindrance than a help. One such metadata often present in PSD/PSB files is the "Description" tag. While metadata serves its purpose, there are instances where we may need to streamline our files, removing unnecessary information to optimize workflows.
mariakenneth
Posts: 1
Joined: Tue Jun 18, 2024 8:57 am

Re: Script to Remove "Description" tag/metadata in PSD/PSB?

Post by mariakenneth »

ambrelangelidou wrote: Sat Feb 11, 2023 12:15 pm Hi, I can't help you but I have an alternative question xD.

Are you able to modify the metadata of your PSD files as you wish? Or can you just delete them?


---------
Improve your scrabble skills https://www.tricher-scrabble.fr omegle
This script effectively removes the 'Description' metadata from PSD, PSB, and JPG files by deleting the corresponding XMP-dc:Description, EXIF:ImageDescription, and IPTC:Caption-Abstract fields. It works reliably on the first run, unlike the previous solution that required multiple executions to completely remove the metadata.