News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

find empty tag

Started by j99mac, May 27, 2020, 02:17:10 PM

Previous topic - Next topic

j99mac

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

StarGeek

Try
exiftool -if "$TAG eq '' "

Replace TAG with the name of the tag you are checking.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

j99mac

How do I use this with artist
exiftool -if "$TAG eq '' "

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


Phil Harvey

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
...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 ($).

j99mac


would this be how I checked if this is add a value to eq "artist"' ?
exiftool -if '$artist eq "artist"' $input_variable

Phil Harvey

Yes.  I think so.  But I'm not clear on what you want to do, and what $input_variable represents.

- 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 ($).

j99mac

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

Phil Harvey

...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 ($).

j99mac

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

Phil Harvey

This means that either Artist didn't exist in the file, or it didn't have a value of "".

- 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 ($).

j99mac

when I ran the command nothing happened or it did not write me to the artist feild.

Phil Harvey

I'm locking this thread because it is a duplicate of this one.

- 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 ($).