Is it possible to write an empty metadata tag on the command line?

Started by Tylerlee12, November 07, 2017, 12:00:49 PM

Previous topic - Next topic

Tylerlee12

Hi all.  Is it possible to write an empty metadata tag using only command line arguments?  I noticed in the documentation that the -json flag does not ignore empty values, and will write them, but I don't want to use a JSON file if at all possible.  Here's the command I'm running right now - xmp:rights and xmp:credit are not being written at all, since their values are empty.

exiftool -m -f -xmp:description="This is a description" -xmp:rights="" -xmp:credit="" "logo+graphic.png"


Phil Harvey

You can't write an empty value directly, but you could filter the XMP afterwards to have this effect.  For example:

1. exiftool -m -xmp:description="This is a description" -xmp:rights=" " -xmp:credit=" " "logo+graphic.png"

2. exiftool -m "-xmp<${xmp;s/> </></g}" "logo+graphic.png"

- Phil

Edit:  I just thought of a sneaky way to generate an empty value, so you could do this in one command, like this:

exiftool -m -xmp:description="This is a description" "-xmp:rights<${filename;$_=''}" "-xmp:credit<${filename;$_=''}" "logo+graphic.png"

or this:

exiftool -m -xmp:description="This is a description" "-xmp:rights<filename" "-xmp:credit<filename" -api filter="$_=''" "logo+graphic.png"
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Note that a new ability was added in ExifTool 10.68 (Dec 5, 2017) to allow tags with empty values to be written using the "^=" operator.  eg)

exiftool -xmp:rights^= FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).