Main Menu

write to tag or use if not

Started by j99mac, November 04, 2021, 10:26:22 AM

Previous topic - Next topic

j99mac

What is better to do write to a tag or use exiftool -if 'not $TagName.

I am looking to only update images that do not have tag filed in and or do not match tag value.

and combine 2 tag in one script

artist and ModifyDate

StarGeek

You can't use use the -if option to conditionally write one tag and unconditionally write another.

But if you're writing the same thing to artist that already exists and you're writing new value for ModifyDate for all file, just write both at the same time.  For example, if half your files already have Artist set to "me" but you're going to change the ModifyDate on all the files anyway, go ahead an rewrite Artist, e.g. -Artist=Me -ModifyDate="2021:11:04 12:00:00".  That would be faster than running two separate commands.
* 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

This is what I tryed
exiftool -r -overwrite_original -artist="$Artist" -ModifyDate=now $path

what about using if vs just over wring command?

StarGeek

That's the same question I just answered.
* 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

would this work
to add a Tag if no tag data is found
exiftool -if "not $ModifyDate" -ModifyDate=now

StarGeek

Test it to see if it's what you want.
* 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

when I run it I get     1 files failed condition

StarGeek

On Mac/Linux, you use single quotes around anything with a dollar sign, otherwise the shell/terminal treats it as a shell variable.
* 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

This is what I am running

I am combing to it with adding Artist tag

exiftool -r -overwrite_original -if "not defined $ModifyDate" -ModifyDate=now -artist="$Artist" "$path"

Phil Harvey

What system are you running?  It seems as if you are using Unix shell variables for $Artist and $path.  If in a Unix shell, you need to do this as StarGeek said:

exiftool -r -overwrite_original -if 'not defined $ModifyDate' -ModifyDate=now -artist="$Artist" "$path"

- 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

I am running the script on OS X
When I run it I get the error Error: Not a valid TIFF (looks more like a MacOS)
Then when I check the files they have ModifyDate, Artist

Phil Harvey

You're running the command on a MacOS resource file if you're getting that error.

- 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 am running
exiftool -r -overwrite_original -if 'not defined $ModifyDate' -ModifyDate=now -artist="$Artist" "$path"

and there is just tiff in my folder

Phil Harvey

Is "$path" the directory name?  If so, you are probably running ExifTool on 2 files.  A TIFF file and the hidden MacOS file.  Use -i HIDDEN to ignore hidden files.

- 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

I am also trying to add tag data if it is missing or there is no data in the field. for example is made does not exist
-if $make =~ ""