I seem to be unable to get this to work:
I want to copy EXIF data from a source file into a dest file. I'm also setting various EXIF fields in this process.
If the dest file does not contain EXIF date and time information (after the copy) I want to set it from other values.
I tried all kinds of "-if" logic, "tag-= tag= " etc. but it does not work. I'm using an ARG file like this:
-overwrite_original_in_place
-m
-all=
-tagsfromfile
c:\source.jpg
# --- What to copy from source
-EXIF:All
-exif:modifydate<FileModifyDate
-TagsFromFile
@
# --- That's the part that does not work:
# Set CreateDate to modified date and time, but only if it does not exist (has not been copied from source)
-exif:CreateDate<FileModifyDate
-if 'not $exif:CreateDate'
# dito
-exif:datetimeoriginal<exif:CreateDate
-if 'not $exif:datetimeoriginal'
# dito
-exif:datetimeoriginal<FileModifyDate
-if 'not $exif:datetimeoriginal'
c:\dest.jpg
That data is copied from source to dest allright. but the copied date and time is always overwritten in dest. It should not, because it already exists.
Any help appreciated.
Your problem is that the -if option applies to the whole command. If the expression returns false, the file is not processed. It can not be applied to individual assignments on the command line.
Instead, to do what you want, simply reverse the order of operations (https://exiftool.org/faq.html#Q22) (since subsequent assignments override earlier ones):
-overwrite_original_in_place
-m
-all=
-TagsFromFile
@
-exif:CreateDate<FileModifyDate
-exif:datetimeoriginal<FileModifyDate
-tagsfromfile
c:\source.jpg
-exif:datetimeoriginal<exif:CreateDate
-EXIF:All
-exif:modifydate<FileModifyDate
c:\dest.jpg
- Phil
Ah, that's smart! :D
ExifTool is always so logical, but there is a lot of it. Thanks, Phil!
Merry Christmas and a Happy New Year to you and your family.