exifexiftool

EXIFTOOL - Set datetime from filename


I have many photos named with a date format but the EXIF dates don't match.

e.g. 2016-12-16_20-20-29.jpg

Running them through EXIFTOOL I can almost overwrite the dates but it doesn't match the exact date format.

exiftool "-datetimeoriginal<filename" ./

This sets the date to the correct calendar day but ignores the time.

exiftool "-datetimeoriginal<filename" -d "%Y-%M-%D_%H-%M-%S.%%e" ./

I believe the -d parameter sets a data format but this returns as error of Warning: Error parsing time in ExifIFD:DateTimeOriginal (PrintConvInv)

Is this the correct method to use?


Solution

  • Your first command should work correctly. From Exiftool FAQ 5:

    ExifTool is very flexible about the actual format of input date/time values when writing, and will attempt to reformat any values into the standard format unless the -n option is used. Any separators may be used (or in fact, none at all). The first 4 consecutive digits found in the value are interpreted as the year, then next 2 digits are the month, and so on. [The year must be 4 digits. Other fields are expected to be 2 digits, but a single digit is allowed if the subsequent character is a non-digit.] "

    The example given following that paragraph is almost the same as your first command.

    The -d option isn't needed for this type of operation.

    Example output

    C:\>exiftool -datetimeoriginal "X:\!temp\2016-12-16_20-20-29.jpg"
    
    C:\>exiftool "-datetimeoriginal<filename" "X:\!temp\2016-12-16_20-20-29.jpg"
        1 image files updated
    
    C:\>exiftool -datetimeoriginal "X:\!temp\2016-12-16_20-20-29.jpg"
    Date/Time Original              : 2016:12:16 20:20:29