ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: karlgustavv on December 10, 2014, 05:34:01 AM

Title: Deleting tags via JSON
Post by: karlgustavv on December 10, 2014, 05:34:01 AM
Hello Phil.

If you want to delete a tag you will do something like:

exiftool -location= test.jpg
or
exiftool -location="" test.jpg

But if you specify

[{
  "SourceFile": "test.jpg",
  "Location": ""
}]


within a JSON-File and apply this to test.jpg the tag "location" won't get deleted. Exiftool leaves test.jpg with an empty location tag.

If this is intended how will I be able to remove tags via JSON?

Regards,
Karl
Title: Re: Deleting tags via JSON
Post by: Phil Harvey on December 10, 2014, 06:57:36 AM
Hi Karl,

From the -json option documentation, you are referred to the -csv option:

            Empty values are ignored when importing.  Also, FileName and
            Directory columns are ignored if they exist (ie. ExifTool will not
            attempt to write these tags with a CSV import).  To force a tag to
            be deleted, use the -f option and set the value to "-" in the CSV
            file (or to the MissingTagValue if this API option was used).
            Multiple databases may be imported in a single command.

- Phil
Title: Re: Deleting tags via JSON
Post by: karlgustavv on December 10, 2014, 12:46:11 PM
Hello Phil,

thank you very much for your fast answer.

So I will replace all "" with "-".

Regards,
Karl

PS: "Empty values are ignored when importing." This might be true for csv imports but with JSON the tag will be set to an ampty value ("Location": "" deletes the original location and sets it to "").
PPS: Stupid question: Is there a way to use -f for deleting tags via "Location": "-" and to keep/set tags that actually have the value "-"?
Title: Re: Deleting tags via JSON
Post by: Phil Harvey on December 10, 2014, 02:05:47 PM
Hi Karl,

Odd.  I will investigate this apparent inconsistency.

- Phil
Title: Re: Deleting tags via JSON
Post by: Phil Harvey on December 10, 2014, 02:20:53 PM
Yes.  This is how it was meant to be.  The difference is due to the difference in format between CSV and JSON.  For JSON, empty values are not ignored.  But I will think about this some more...  Perhaps setting MissingTagValue to an empty string could trigger the behaviour you desire.

- Phil
Title: Re: Deleting tags via JSON
Post by: Phil Harvey on December 11, 2014, 02:02:18 PM
OK.  Setting MissingTagValue to an empty string works, but this must be done via the API (you can do this with a config file) because you can't set something to an empty string via the command line.

Also, I'll see about improving the -json documentation of this.

- Phil
Title: Re: Deleting tags via JSON
Post by: karlgustavv on December 11, 2014, 06:57:19 PM
Hi Phil,

adding

%Image::ExifTool::UserDefined::Options = (
    MissingTagValue => '',
);


to a config file really does the job.

Thanks a lot.

Regards,
Karl