Extracting date taken from .nef raw nikon file

55 Views Asked by At

I am trying to extract the "date taken" metadata from a Nikon RAW file (.nef) **without **converting it to an image file (.png, .jpg, .webp, .etc.). I can hover a mouse over a raw file and windows pops up an info box with the required data, so it must be there in some format, and I would think it should be accessible without adding a 3rd party codec or library.

Virtually every "solution" to the problem is retrieving the date taken from an image file like a jpg using propertyitems. this is NOT what I need. I need to extract from the raw .nef file. I haven't yet found a solution. Th closes I got was finding a file specification for the .nef file, but I can't seem to translate into anything that works. Here is a link to that spec. https://exiftool.org/TagNames/Nikon.html

1

There are 1 best solutions below

3
Mark Setchell On

exiftool is your friend. Here I tell it to list all the tags that contain the word "date":

exiftool '-*Date*' sample/images/Nikon.nef

Output

File Modification Date/Time     : 2019:03:22 17:56:09+00:00
File Access Date/Time           : 2023:07:13 13:10:36+01:00
File Inode Change Date/Time     : 2023:07:13 13:10:33+01:00
Modify Date                     : 2012:12:19 16:49:33
Create Date                     : 2012:12:19 16:49:33
Date Display Format             : D/M/Y
Date/Time Original              : 2012:12:19 16:49:33
Create Date                     : 2012:12:19 16:49:33.10
Date/Time Original              : 2012:12:19 16:49:33.10
Modify Date                     : 2012:12:19 16:49:33.10

If you want exiftool to tell you the variable name you should use, add the -S option:

exiftool '-*Date*' -S sample/images/Nikon.nef

Output

FileModifyDate: 2019:03:22 17:56:09+00:00
FileAccessDate: 2023:07:13 13:10:36+01:00
FileInodeChangeDate: 2023:07:13 13:10:33+01:00
ModifyDate: 2012:12:19 16:49:33
CreateDate: 2012:12:19 16:49:33
DateDisplayFormat: D/M/Y
DateTimeOriginal: 2012:12:19 16:49:33
SubSecCreateDate: 2012:12:19 16:49:33.10
SubSecDateTimeOriginal: 2012:12:19 16:49:33.10
SubSecModifyDate: 2012:12:19 16:49:33.10

Then, if you decide the field/tag you want is DateTimeOriginal, you will know that you need to run:

exiftool -DateTimeOriginal sample/images/Nikon.nef 

Output

Date/Time Original              : 2012:12:19 16:49:33

exiftool -ImageWidth -ImageHeight sample/images/Nikon.nef

Output

Image Width                     : 7424
Image Height                    : 4924

Other formats, such as pure numbers without tag names are also possible:

exiftool -ImageWidth -ImageHeight -s3 sample/images/Nikon.nef

Output

7424
4924