Parameters for creating [EXIF] DateTimeOriginal - tag

Started by jojomimi, January 30, 2020, 05:31:09 AM

Previous topic - Next topic

jojomimi

Hi,

I'm on Linux Mint.  For some reason, I'm missing the "DateTimeOriginal" info in many of my pictures but I could use "FileModifyDate" as this one seems to be close to the timestamp I'm looking for.

Question :
I can't find how to create the "[EXIF] DateTimeOriginal" - tag.
I also can't find how to copy the "[File] FileModifyDate" value into this field.

Example :

exiftool -G -s 8576d6366939e3fe0000000000000000.jpg

[ExifTool]      ExifToolVersion                 : 10.80
[File]          FileName                        : 8576d6366939e3fe0000000000000000.jpg
[File]          Directory                       : .
[File]          FileSize                        : 70 kB
[File]          FileModifyDate                  : 2018:01:04 11:51:14+01:00
[File]          FileAccessDate                  : 2020:01:29 23:33:27+01:00
[File]          FileInodeChangeDate             : 2020:01:27 21:52:50+01:00
[File]          FilePermissions                 : rwxrwxrwx
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[File]          ImageWidth                      : 1183
[File]          ImageHeight                     : 360
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:0 (2 2)
[JFIF]          JFIFVersion                     : 1.01
[EXIF]          Software                        : Picasa
[EXIF]          ExifVersion                     : 0220
[EXIF]          ColorSpace                      : sRGB
[EXIF]          ExifImageWidth                  : 1183
[EXIF]          ExifImageHeight                 : 360
[EXIF]          InteropIndex                    : R98 - DCF basic file (sRGB)
[EXIF]          InteropVersion                  : 0100
[EXIF]          ImageUniqueID                   : 8576d6366939e3fe0000000000000000
[EXIF]          Compression                     : JPEG (old-style)
[EXIF]          XResolution                     : 72
[EXIF]          YResolution                     : 72
[EXIF]          ResolutionUnit                  : inches
[EXIF]          ThumbnailOffset                 : 312
[EXIF]          ThumbnailLength                 : 3320
[EXIF]          ThumbnailImage                  : (Binary data 3320 bytes, use -b option to extract)
[XMP]           XMPToolkit                      : XMP Core 5.5.0
[Composite]     ImageSize                       : 1183x360
[Composite]     Megapixels                      : 0.426

I want to copy the FileModifyDate value ("2018:01:04 11:51:14+01:00") into below fields, if they don't exist yet in my picture :
[EXIF]          DateTimeOriginal                :
[EXIF]          CreateDate                      :

Can someone help me ?

Phil Harvey

There is lots of wiggle room here.  To fill in DateTimeOriginal and CreateDate with FileModifyDate if they are empty, you can do this:

exiftool -addtagsfromfile @ -datetimeoriginal-= "-datetimeoriginal<filemodifydate" -createdate-= "-createdate<filemodifydate" FILESorDIRS

But I would think it would be better to fill in CreateDate with DateTimeOriginal if it exists, and visa versa, and only use FileModifyDate if necessary:

exiftool -addtagsfromfile @ -datetimeoriginal-= "-datetimeoriginal<filemodifydate" "-datetimeoriginal<createdate" -createdate-= "-createdate<filemodifydate" "-createdate<datetimeoriginal" FILESorDIRS

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

jojomimi

Hi Phil,

What a quick reply !  I'll test this tonight.

I forgot to add that I want to keep the original .jpg files unchanged and store these tags in .jpg.xmp sidecar files.

Is this feasible as well ?

Brgds,
Michael

Phil Harvey

Hi Michael,

This gets more complicated, but here you go:

exiftool -addtagsfromfile @ -datetimeoriginal-= "-datetimeoriginal<filemodifydate" "-datetimeoriginal<createdate" -createdate-= "-createdate<filemodifydate" "-createdate<datetimeoriginal" -srcfile %d%f.%e.xmp -ext jpg FILESorDIRS

See example 13 here.

Lots of wiggle room here too.  This will add DateTimeOriginal to the XMP if it doesn't exist in the XMP.  I would have to think more about this if you want to add it to the XMP only if it doesn't exist in the JPG.

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

Alan Clifford

Quote from: jojomimi on January 30, 2020, 07:41:22 AM

I forgot to add that I want to keep the original .jpg files unchanged and store these tags in .jpg.xmp sidecar files.

datetimeoriginal in exif is not the same field as datetimeoriginal in xmp.


Phil Harvey

Good Point.  In XMP, DateTimeOriginal is better copied to XMP-photoshop:DateCreated.  CreateDate is OK though, and should go to XMP-xmp:CreateDate.

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

jojomimi

Great, it works !

This XMP has been generated :

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 10.80'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:DateTimeOriginal>2018-01-04T11:51:14+01:00</exif:DateTimeOriginal>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
  <xmp:CreateDate>2018-01-04T11:51:14+01:00</xmp:CreateDate>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

Last question :

Can I make this command conditional ?  In some cases, my pictures already already contain this "CreateDate" tag (containing correct information !), how can I avoid overwriting this with the "FileModifyDate" tag (which is less reliable)?

Phil Harvey

What do you mean?  You won't be overwriting the CreateDate in your pictures because you are writing sidecar files, not the picture 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 ($).

jojomimi

Indeed, sorry for the confusion, I mean :

In some cases, my XMP files (not pictures) already contain this "CreateDate" tag (containing correct information !), how can I avoid overwriting this with the "FileModifyDate" tag (which is less reliable) ?

Phil Harvey

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

jojomimi

You're right Phil, it works !
Many, many thanks !
Brgds,
Michael