News:

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

Main Menu

settings dates on for ones that don't exist?

Started by zmw, November 26, 2016, 06:40:02 PM

Previous topic - Next topic

zmw

I found a couple other threads addressing this - but my situation seems to not be addressed by any of them.

I have thousands of files that do not have datetimeoriginal, createdate, or modifydate set - They do however have filemodifydate

Is there a way to ONLY set files that do NOT have the above set? I realize I can set all of them from filemodifydate by using exiftool -alldates<filemodifydate but I only want to execute that IF the 3 above don't exist and I can't seem to figure how to check for a non existent tag.

What I don't want to do is start a recursive replacement of alldates with filemodifydate and end up resetting ones that I've already fixed by hand like this one for example.

Date/Time Original              : 2010:02:07 21:35:36
Create Date                     : 2010:02:07 21:35:36
Modify Date                     : 2010:02:07 21:35:36
File Modification Date/Time     : 2016:11:26 17:28:28-06:00

obviously the filemodifydate has changed since I updated the exif data

Thanks - Zach

Paul Barrett

As I understand it, if you write to a date tag that doesn't already exist in the metadata, it will be created and populated.IIRC

- Paul

Phil Harvey

You can do it like this:

exiftool "-datetimeoriginal<filemodifydate" -if "not $datetimeoriginal" DIR

This will copy FileModifyDate to (for example) DateTimeOriginal if it doesn't already exist.

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

zmw

Is there a way to "test" this - I was trying to use -echo hello with -if but it seems to echo hello no matter if the IF condition is met.


Alan Clifford

Quote from: zmw on November 28, 2016, 12:45:04 PM
Is there a way to "test" this - I was trying to use -echo hello with -if but it seems to echo hello no matter if the IF condition is met.

exiftool -filename -if 'not $datetimeoriginal' .


======== ./pixel.jpg
File Name                       : pixel.jpg
======== ./temp.jpg
File Name                       : temp.jpg
    1 directories scanned
   52 files failed condition
    2 image files read


You'll probably need " rather than ' under Microsoft windows.


Next test would be to copy a few files to a new directory and run the re-dating command on that directory.