Only if DateTimeOriginal is missing..

Started by tdiaz, June 17, 2017, 06:25:47 PM

Previous topic - Next topic

tdiaz

I'd like to set DateTimeOriginal to the Filesystem created date entry if there is no existing entry, and only if it was updated, to also add a keyword to reflect that:

Something along the lines of:

exiftool -r -if "not $datetimeoriginal" -metadatadate="FileCreatedDate" -keywords+=DateMissing DIR

I'm unsure how to build the syntax for that .. 

I presume the syntax would be similar for other missing data, (eg: Camera Model = "Mine" if there is no existing value) as well.

StarGeek

You're pretty close, just some minor details to work out.   

exiftool -r -if "not $DateTimeOriginal" "-DateTimeOriginal<FileCreateDate" -keywords+=DateMissing DIR

The equal sign is used to assign a static value to a tag.  In your case, you want to copy one tag to another, so you have to use the greater/less than sign. 

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

tdiaz

Something isn't jiving ..


ICBM:4 tdiaz$ exiftool -d "%r %a, %B %e, %Y" -DateTimeOriginal -S -s *.JPG
======== DSCN0042 copy.JPG
09:10:36 pm Mon, January  5, 2004
======== DSCN0042.JPG
09:10:36 pm Mon, January  5, 2004
======== IMG_2806.JPG
08:56:41 am Tue, January 19, 2010
======== IMG_2807.JPG
09:18:56 am Tue, January 19, 2010
======== IMG_2809.JPG
09:19:42 am Tue, January 19, 2010
======== IMG_3004 copy.JPG
======== IMG_3004.JPG
======== IMG_3005.JPG
======== IMG_3006.JPG
    9 image files read

ICBM:4 tdiaz$ exiftool -r -if "not $DateTimeOriginal" "-DateTimeOriginal<FileCreateDate" -keywords+=DateMissing .
    1 directories scanned
   10 files failed condition
    0 image files read


StarGeek

Replace double quotes with single quotes when not on Windows.  Also, if on linux, there is no FileCreateDate from what I understand.  You'll have to use something else, maybe FileModifyDate?  If on Mac, I think you can use MDItemFSCreationDate.

Try running exiftool -time:all -g1 -a -s to see all the time tags and figure out which one is the one that would work for you.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

tdiaz

Funny thing, there .. with the double quotes. It worked on other things. ;-)

Got it figured out. All good. :) Thanks!

tdiaz

This is what I ended up with:

exiftool -r -if 'not $DateTimeOriginal' '-DateTimeOriginal<FileModifyDate' '-FileModifyDate<DateTimeOriginal' -keywords+=DateMissing1  -make="SONY" -model="Mavica FD-71" '-country=Japan' '-city=Tokyo' -overwrite_original . ;exiftool -r  '-FileModifyDate<DateTimeOriginal'  -overwrite_original .

How can I get that second command to only happen if one of the keywords in the file is "MissingDate1"? As I can't seem to get it to set the FileModifyDate back, or leave it alone within the initial command.

A couple of variances I've tried:

exiftool -r -if '-keywords=*DateMissing1*'  '-FileModifyDate<DateTimeOriginal'  -overwrite_original .
exiftool -r -if '-keywords=DateMissing1'  '-FileModifyDate<DateTimeOriginal'  -overwrite_original .

StarGeek

Quote from: tdiaz on June 18, 2017, 04:35:01 AM
Funny thing, there .. with the double quotes. It worked on other things. ;-)

It has to do with the bash shell.  Bash interprets dollar signs as a variable when enclosed in double quotes.  You can use double quotes otherwise, but it's just good practice to use single quotes on Mac/Linux.

The argument to the -if option is basically a Perl expression (see -if docs).

The simplest thing you can do is use a Perl regex to get a match -if '$Keywords=~/MissingDate1/'
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype