ExifTool Forum

ExifTool => Newbies => Topic started by: j99mac on May 27, 2020, 02:17:10 PM

Title: find empty tag
Post by: j99mac on May 27, 2020, 02:17:10 PM
I am looking to find out if a tag is empty? How to do you you if to check if a tag is blank of have anything written in it
Title: Re: find empty tag
Post by: StarGeek on May 27, 2020, 02:32:31 PM
Try
exiftool -if "$TAG eq '' "

Replace TAG with the name of the tag you are checking.
Title: Re: find empty tag
Post by: j99mac on May 28, 2020, 07:26:55 AM
How do I use this with artist
exiftool -if "$TAG eq '' "

Is this how I write the comand
exiftool -if "$artist eq '' " dir

Title: Re: find empty tag
Post by: Phil Harvey on May 28, 2020, 08:23:32 AM
Your quotes are wrong.  It should be

exiftool -if "$artist eq ''" DIR

(on Windows)

or

exiftool -if '$artist eq ""' DIR

(on Mac/Linux)

This will check if the tag exists but the value is empty.  If you want to also check if the tag doesn't exist, do this:

exiftool -if "not defined $artist or $artist eq ''" DIR

- Phil
Title: Re: find empty tag
Post by: j99mac on May 28, 2020, 08:25:47 AM

would this be how I checked if this is add a value to eq "artist"' ?
exiftool -if '$artist eq "artist"' $input_variable
Title: Re: find empty tag
Post by: Phil Harvey on May 28, 2020, 08:27:24 AM
Yes.  I think so.  But I'm not clear on what you want to do, and what $input_variable represents.

- Phil
Title: Re: find empty tag
Post by: j99mac on May 28, 2020, 08:33:57 AM
this is what I would like do
if the artist tag is empty then write to artist tag

for input_variable I want it to a file path

echo "Enter the file path"
   read input_variable
exiftool -if '$artist eq ""' $input_variable
exit 0
Title: Re: find empty tag
Post by: Phil Harvey on May 28, 2020, 09:46:44 AM
See my response here (https://exiftool.org/forum/index.php?topic=10931.msg60192#msg60192)
Title: Re: find empty tag
Post by: j99mac on May 28, 2020, 11:20:44 AM
I tried the command like this and it did not add me to the image iwth no artist

echo "Enter the file path"
   read dir
exiftool -if '$artist eq ""' -artist="me" $dir
exit 0
Title: Re: find empty tag
Post by: Phil Harvey on May 28, 2020, 02:15:59 PM
This means that either Artist didn't exist in the file, or it didn't have a value of "".

- Phil
Title: Re: find empty tag
Post by: j99mac on May 28, 2020, 02:23:09 PM
when I ran the command nothing happened or it did not write me to the artist feild.
Title: Re: find empty tag
Post by: Phil Harvey on May 28, 2020, 03:40:30 PM
I'm locking this thread because it is a duplicate of this one (https://exiftool.org/forum/index.php?topic=10931).

- Phil