Set the file modification and creation date from EXIF info

Started by Joseph Allan, April 28, 2013, 10:37:25 PM

Previous topic - Next topic

Phil Harvey

It seems that CreateDate is not available.

To see the available date/time tags, use this command:

exiftool -a -G1 -s -time:all FILE

Also, I would suggest using the -ext option instead of testing FileType to avoid needlessly parsing non-jpeg files:

exiftool '-datetimeoriginal<createdate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .

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

stefanoanzilotti


Thank you Phil.

You were right, I got this output:


MacBookProWireless:test myname $ exiftool -a -G1 -s -time:all DailyLife00321.jpg
[System]        FileModifyDate                  : 2018:01:29 18:55:09+01:00
[System]        FileAccessDate                  : 2018:02:20 20:06:53+01:00
[System]        FileInodeChangeDate             : 2018:02:20 20:06:51+01:00
[XMP-xmp]       MetadataDate                    : 2018:01:29 18:55:09+01:00
[XMP-xmpMM]     HistoryWhen                     : 2018:01:29 16:32:29+01:00, 2018:01:29 18:55:09+01:00


Then, do you maybe know how can I get the created data info?

I attached two images about the file that I am talking about to be clear.



StarGeek

I haven't checked in a bit but when I looked at Adobe Bridge ver 7.0.0.93, the "Date Created" property was filled with these tags, in descending priority

  • XMP-exif:DateTimeOriginal
  • EXIF:DateTimeOriginal
  • XMP-photoshop:DateCreated
  • IPTC:DateCreated + IPTC:TimeCreated
  • XMP-xmp:CreateDate
  • XMP-pdf:CreationDate
  • XMP-exif:DateTimeDigitized
  • IPTC:DigitalCreationDate + IPTC:DigitalCreationTime
  • EXIF:CreateDate
  • XMP-xmp:ModifyDate
  • XMP-pdf:ModDate
  • EXIF:ModifyDate
  • System:FileCreateDate
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

stefanoanzilotti


Sorry StarGeek, but I am a beginner.
I found some of this tags in Adobe, but I have not idea how to fix the problem.

Do you have some advice for edit my command?


StarGeek

Quote from: stefanoanzilotti on February 20, 2018, 03:22:02 PM
I found some of this tags in Adobe, but I have not idea how to fix the problem.

Sounds like I wasn't quite clear enough.  That list I gave is just the "Date Created" entry in Adobe Bridge.  Bridge will go down that list until it finds one of those tags and use that as the "Date Created"

QuoteDo you have some advice for edit my command?

Unfortunately, no.  I don't use a Mac so I have no idea where it is pulling it's "Date Created" property from.  It doesn't show up on the output you gave for the Time:All command, which I find really confusing.

Even though FileCreateDate doesn't show up on your output, maybe try to use it? 
exiftool '-DateTimeOriginal<FileCreateDate'
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

stefanoanzilotti

Quote from: StarGeek on February 20, 2018, 03:39:38 PM
Sounds like I wasn't quite clear enough. 

Everything is new for me right now (command line first), but I like it already.

Quote from: StarGeek on February 20, 2018, 03:39:38 PM
It doesn't show up on the output you gave for the Time:All command, which I find really confusing.

I really don't understand how could be possible that I see the real 'Created Data' in the finder, but I cannot see the info on the terminal.

Anyway, I trayed this command:

exiftool '-DateTimeOriginal<FileCreateDate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .


Still same output.   :(

Phil Harvey

On Mac, the file creation date is MDItemFSCreationDate.  See the MacOS tags for an explanation.

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

stefanoanzilotti


As you said, I found the file creation date is MDItemFSCreationDate using the command:

$ mdls photoname.jpg

Maybe I can copy this value to 'DataTimeOriginal' field?

Phil Harvey

exiftool '-datetimeoriginal<MDItemFSCreationDate' -overwrite_original_in_place -P FILE

Here I have added -overwrite_original_in_place to prevent the file creation date/time from being set to the current time when the file is rewritten, and -P to preserve the file modification date/time.

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

stefanoanzilotti


That's working amazingly! Thank you so much!

I would like also to skip the files that already have 'datatimeoriginal' field fixed. I trayed to marge the previous commands, but I got an error.

exiftool '-datetimeoriginal<MDItemFSCreationDate' -overwrite_original_in_place -P -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .


Phil Harvey

It would help if you told me what the error was.

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

stefanoanzilotti


The error is:


MacBookProWireless:test stefanoanzilotti$ exiftool '-datetimeoriginal<MDItemFSCreationDate' -overwrite_original_in_place -P -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -ext jpg -ext jpeg .
    1 directories scanned
    2 files failed condition
    0 image files read


I thought about a syntax mistake.

Phil Harvey

So there was no error after all?  Just all files failed the condition.  To see why, take a look at DateTimeOriginal for these files.  If it exists and isn't all zeros, then the condition will fail.

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

stefanoanzilotti


Then, I made some tests.
Actually, everything works right if the field 'DataTimeOriginal' is free. The command does not work if I manually delete the field for testing the command. I still do not figure out why that happened.

I really appreciated the help. Useful forum!  ;)

stefanoanzilotti


I was wondering other one question: is the opposite operation possible? In other words, I would like to set the 'Data File Created' as the 'DataTimeOriginal'?