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

Hi Dave,

I'm sure ExifTool can do what you want, but to give more specific help I will need examples of all of the combinations of input date/time formats and what you want them converted to.

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

dld44

Phil, I'm collecting a bunch of date info in this manner:
exiftool -time:all -a -G0:1 -s
I can give you the output examples as
EXIF:ExifIFD (example: [EXIF:ExifIFD]  DateTimeOriginal                : 1942:  :   00:00:00)
or XMP XMP-exif (example: [XMP:XMP-exif]  DateTimeOriginal                : 1942).
I expect you want the EXIF:ExifIFD version, but please let me know so I include the right stuff.
Depending upon how much of the date I entered, the version of Elements I used and whether it was a scan or photo, there are a lot of combinations
Dave

Phil Harvey

Hi Dave,

Using the EXIF version may be easier. 

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

dld44

Hi Phil,

What I would like to accomplish, all in batch mode, is to take whatever DateTimeOriginal metadata is included and round it out with a complete Date/Time entry (perhaps placing any digit that would return a valid date/time in the fields that are currently blank or "00") so I can move DateTimeOriginal into the FileCreateDate and/or the FileModifyDate without error. Then any online viewing application would be able to sort by what will then amount to the original date (as I stated in my original entry).

I've included the file date information from a number of scans. Most if not all of these were scanned as TIFs; I batched saved JPG copies with Photoshop several days ago in preparation for placing them online. The metadata is always duplicated properly to the JPG copy. Since only DateTimeOriginal appears to be relevant, I've included only that in the samples below.

The original date of each photo was input into Photoshop Elements Organizer by me when I scanned the photo, and that value went into DateTimeOriginal (sometimes--see below >:(). Over the years that I have been doing this I have used three Elements versions--3, 5, and 9--which appear to have used different methods to store date information.

Where I have entered a complete date and time it looks like this:
[EXIF:ExifIFD]  DateTimeOriginal                : 1985:09:15 18:02:20
The following samples were photo dates input with Elements 3.0 and 5.0:
[EXIF:ExifIFD]  DateTimeOriginal                : 1967:  :   00:00:00
[EXIF:ExifIFD]  DateTimeOriginal                : 1910:01:   00:00:00
[EXIF:ExifIFD]  DateTimeOriginal                : 1905:01:01 00:00:00


However, in scans that were done with Elements 9.0, DateTimeOriginal is not set at all. I have found some complaints online about that, but it is unclear whether this is a bug or a feature (Adobe always advertised that they wrote the metadata directly to the file and they don't appear to keep sidecars, but Adobe support is so poor that it's impossible to tell whether they mean to do it this way in 9.0). So I will also need to find a way to separate out those jpgs with no DateTimeOriginal tag so I can process them separately (using tag Creator Tool  : Elements Organizer 9.0). Luckily not too many scans have been made with 9.0.

Finally, taking the close look at Adobe Photoshop Elements that I was forced to do in these last few days has exposed some real uglies on the underbelly of that product. I have been considering moving away from PE for some time, but I believe I now have the impetus to do so. So I need some advice about where to go. I'm not at all a fan of Adobe for various reasons, mostly the problems they have caused in my Android world by no longer supporting Flash Player, but also lots of others, so would like to go somewhere else entirely. Suggestions, anyone?

DaveD

Phil Harvey

Hi Dave,

Thanks.  Try this:

exiftool "-filemodifydate<${datetimeoriginal;s/  /01/g}" FILE

Note that depending on your system you may or may not have success setting filesystem times to a date before 1970.

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

dld44

Phil,
No success.
Here's the log:
Grabbed all time info from sample.jpg:
[File:System]   FileModifyDate                  : 2014:06:14 11:11:37-04:00
[File:System]   FileAccessDate                  : 2014:06:14 11:11:37-04:00
[File:System]   FileCreateDate                  : 2014:06:14 11:11:37-04:00
[EXIF:IFD0]     ModifyDate                      : 1967:00:00 00:00:00
[EXIF:ExifIFD]  DateTimeOriginal                : 1967:  :   00:00:00
[EXIF:ExifIFD]  CreateDate                      : 1967:00:00 00:00:00
[XMP:XMP-xmp]   CreateDate                      : 2014:06:13 11:10:27-04:00
[XMP:XMP-xmp]   MetadataDate                    : 2014:06:13 11:10:27-04:00
[XMP:XMP-xmp]   ModifyDate                      : 2014:06:13 11:10:27-04:00
[XMP:XMP-exif]  DateTimeOriginal                : 1967
[XMP:XMP-exif]  DateTimeDigitized               : 1967:02
[ICC_Profile:ICC-header] ProfileDateTime        : 1999:06:03 00:00:00
<-END-

Entered on ExifToolGUI command line: "-filemodifydate<${datetimeoriginal;s/  /01/g}"
Log message:
======== ./sample.jpg
Nothing changed in ./sample.jpg
    0 image files updated
    1 image files unchanged
Warning: No writable tags set from ./sample.jpg
<-END-
         

And, I couldn't for the life of me determine just what your ExifTool options were all about. Would it be possible to give a short description of the syntax used? It would go a long way for me understanding how to use this tool.
Thanks,
Dave                 

Phil Harvey

#21
Hi Dave,

You must be using a very old version of ExifTool.  You must use version 9.30 or later for the advanced formatting feature.  The basic redirection syntax is explained in the -tagsFromFile section of the application documentation, which refers to the -p option for a description of the advanced formatting feature.  The expression I used substitutes all instances of "  " for "01" in the value of DateTimeOriginal before it is copied to FileModifyDate.

- Phil

Edit:  Tried to explain better where to find this in the documentation.
...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 ($).

dld44

Hi Phil,

I'm using the ExifTool Windows Executable 9.64 downloaded from your site yesterday. I'm looking at the documentation on https://exiftool.org/exiftool_pod.html#synopsis, and linking to examples.

But it's me. I haven't yet found the courage to explore this tool as I must if I am going to use it productively. I spent many productive years in IT accomplishing tasks using a command line interface, but I've become lazy in my old age after so many years of using GUIs.

So I'll spend some time trying to figure this one out from your short explanation above, and get back to you after I know a bit more. Unless, of course, you have some additional suggestions in the meantime.

Thanks again,
Dave

Phil Harvey

Hi Dave,

Another possible problem is that my quoting assumes you were using the Windows cmd shell.  In other shells you would need to use single quotes instead of double quotes around any argument containing a '$' symbol.

- Phil

Edit: Also, to make sure it takes the EXIF DateTimeOriginal, it would be best to do this:

exiftool "-filemodifydate<${exif:datetimeoriginal;s/  /01/g}" FILE
...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 ($).

dld44

Phil,

This works:
exiftool "-createdate<${datetimeoriginal;s/  /01/g}".
No need to specify the EXIF tag in the case of datetimeoriginal (or createdate). But perhaps I need to specify the filesystem tag type for the filemodifydate? I haven't found how to do that. -file:filemodifydate and -file:system:filemodifydate don't work.

I'm using Windows, with double quotes. I also tried running ExifTool in a cmd window, same results. So ExifToolGUI isn't getting the way. Actually, its kind of nice to use the GUI ExifTool direct command line, as it makes for a lot less typing, like entering my rather long file names with spaces inside quotes, etc.

Dave

Edit: Well now, I tried a new photo, taken in 2012, and it worked just like it should, setting the file system modified date to 1/1/2012 12:00 AM (as displayed in Windows) from a DateTimeOriginal date of 2012:  :   00:00:00. I don't believe that Windows has an date epoch anywhere within the last several hundred years--it appears to be 1 January 1601. Could it be Perl causing this? Perl has a date epoch of 1 January 1970 (http://en.wikipedia.org/wiki/System_time). Or is it something else?

Phil Harvey

Right.  The 1970 problem as I mentioned.

The standard C library functions which are the basis of the Perl libraries use a time zero of 1970.  On some systems though (typically 64-bit systems), negative times are allowed.  But the Windows .exe version of ExifTool is not 64 bit.

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

dld44

Rats! I was so close to getting it done. I tried a few more samples, on both sides of 1/1/1970, and verified that this is indeed the problem. So on to plan "B", although I have not yet identified just what that might be. At least I can get the invalid dates straightened out with ExifTool's substitution capability.

Thanks for all your assistance.
Dave

babyphat1

Hello Phil,

I've tried the following for my video but seems like there is no data. So how am I supposed to change it to its original time?

C:\Users\watev>exiftool -time:all -a -G0:1 -s C:\Users\watev\Desktop\Video047.mp4
[File:System]   FileModifyDate                  : 0000:00:00 00:00:00
[File:System]   FileAccessDate                  : 0000:00:00 00:00:00
[File:System]   FileCreateDate                  : 0000:00:00 00:00:00
[QuickTime]     CreateDate                      : 0000:00:00 00:00:00
[QuickTime]     ModifyDate                      : 0000:00:00 00:00:00
[QuickTime:Track1] TrackCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track1] TrackModifyDate              : 0000:00:00 00:00:00
[QuickTime:Track1] MediaCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track1] MediaModifyDate              : 0000:00:00 00:00:00
[QuickTime:Track2] TrackCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track2] TrackModifyDate              : 0000:00:00 00:00:00
[QuickTime:Track2] MediaCreateDate              : 0000:00:00 00:00:00
[QuickTime:Track2] MediaModifyDate              : 0000:00:00 00:00:00

What should I do about this?
Any help?

Phil Harvey

There seems to be no date/time information available here.  In this case you must set it manually, ie)

exiftool -wm w -time:all="2017:09:17 08:00:00" FILE

- 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


Hi everyone,
I'm trying to do something like you did in this post, obviously without luck.

I would like to copy the 'Data Created' to the 'Data Time Original' field of Adobe Bridge (image attached).

I used the following command:

exiftool '-datetimeoriginal<createdate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' *


The output is:


Warning: No writable tags set from DailyLife00321.jpg
Warning: No writable tags set from DailyLife00322.jpg
    0 image files updated
    2 image files unchanged


Thank you guys