EXIFTOOL Config File

Started by klind, August 29, 2024, 10:14:08 PM

Previous topic - Next topic

klind

Hi, all:

I wrote (with much help) the following configuration file some time back:

```
%Image::ExifTool::UserDefined = (
   'Image::ExifTool::Composite' => {
      MyDate => {
         Desire => {
            0 => 'DateTimeOriginal',
            1 => 'CreateDate',
            2 => 'ModifyDate',
            3 => 'FileModifyDate',
            4 => 'DateTimeDigitized',
            5 => 'MDItemFSCreationDate',
         },
         ValueConv => q{
            my ($earliest) = (sort {$a cmp $b} grep $_, @val)[0];
            return $earliest;
         },
         PrintConv => '$self->ConvertDateTime($val)',
      },
   },
);
```

I call it with the following command line with my MacOS computer:

ExifTool -config myexiftool.config '-datetimeoriginal<mydate' '-MDItemFSCreationDate<mydate' -P -F -d %Y-%m-%d -'filename<${mydate} ~${filename}' -overwrite_original_in_place

As is everything works very well and I get my filenames adjusted accordingly.

However recently, due to deaths in the family, I have been overwhelmed with the input of a great many, actually many thousands, of photo files that now need some tender loving care.

I have recently learned that there may be as many as 60 places within the meta data that may contain date information. So now what I wish to do is use exiftool to seek out and find the earliest possible date anywhere in the meta data and write that date back to AllDates AND also change the filename like I did before so as to match my current database of photo files.

I can probably get the command line written correctly, but I am not sure how to tackle the configuration file situation. Is there a simple way to get exiftool to search for and identify the earliest possible date? If not, I would like to modify my configuration file to look at as many date entries as possible, or at least the most common ones. Is there a listing somewhere of all possible meta data date entries?

Any and all suggestions are welcome.

Regards,

Ken
Ken Lind

StarGeek

There are actually more than 60. You can run this command and exiftool will write all time related tags it can write into the file that are not marked Avoid
exiftool -Time:All=now /path/to/files/

Running it right now gives me about 90 tags. If you added the Avoid tags, it would be more, about 103.

But the good news is that most of them will not be found in a normal files, and some of them are unsuitable for dating the file. I would suggest this. Run exiftool over large number of files to get a list of all the date time tags that are in them, pipe the results through sort and uniq and look over the result list. Something like (I think, I don't use sort and uniq that often)
exiftool -G1 -a -s -Time:all -r /path/to/files/ |sort |uniq >temp.txt

You can then open the list in a text editor and strip away all the filenames. The results should be a list of all the tags you would want to look at. I can tell you right off the XMP-xmpDM tags should be ignored, as they are used for editing history, version control, and aren't really meant to be used by humans.

In my opinion, these are the only tags, other than the file system ones, that you need worry about. Any other tags are unlikely to be useful or accurate, IMO. This is basically a copy/paste directly from my config file

# Timestamp when photo was taken
'EXIF:DateTimeOriginal','EXIF:OffsetTimeOriginal',      # EXIF DateTimeOriginal tags
'XMP:DateTimeOriginal','XMP:DateCreated',               # XMP DateTimeOriginal tags

# Timestamp when photo was digitized, always the same for camera pictures, different for scans
'EXIF:CreateDate', 'EXIF:OffsetTimeDigitized',          # EXIF CreateDate (DateTimeDigitized) tags
'XMP:CreateDate', 'XMP:DateTimeDigitized',              # XMP CreateDate tags

# Timestamp when photo was modified, not really used but filled in for completeness
'EXIF:ModifyDate', 'EXIF:OffsetTime',                   # EXIF ModifyDate tags
'XMP:ModifyDate',                                       # XMP ModifyDate tags

# GPS Timestamps
'GPS:GPSDateStamp','GPS:GPSTimeStamp','XMP:GPSDateTime',

# IPTC DateTimeOriginal tags
'IPTC:DateCreated','IPTC:TimeCreated',
# IPTC CreateDate tags
'IPTC:DigitalCreationDate', 'IPTC:DigitalCreationTime',

But taking it a step further, the EXIF and IPTC date is spread across multiple tags. For your purposes, I would suggest using these composite tags instead of the EXIF and IPTC ones. The XMP tags would be used as is
SubSecCreateDate         : Combined EXIF CreateDate tags
SubSecDateTimeOriginal   : Combined EXIF DateTimeOriginal tags
SubSecModifyDate         : Combined EXIF ModifyDate tags
DateTimeCreated          : Combined IPTC DateTimeOriginalcreated tags
DigitalCreationDateTime  : Combined IPTC CreateDate created tags

Whichever tags you want to use, all you would need to do is add them to the Desire section in the same format. The next number in the sequence, <Equal><GreaterThan> =>, the tag name (capitalization matters) in single quotes, and then a comma

For example:
      MyDate => {
         Desire => {
            0 => 'DateTimeOriginal',
            1 => 'CreateDate',
            2 => 'ModifyDate',
            3 => 'FileModifyDate',
            4 => 'DateTimeDigitized',
            5 => 'MDItemFSCreationDate',
            6 => 'DateTimeCreated',
            7 => 'DigitalCreationDateTime',
         },
* 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).

klind

#2
Thanx StarGeek, great data.

A question: While what I want to discern is the earliest date in the meta data, I notice that your command searches for 'time'. I learned from this and found it interesting. I never would have thunk to search for 'time' when I want to know about dates...

I ran your suggested command to learn about dates in my pile of filenames. I randomly selected about 200 files and the resulting temp.txt file returned the following:

[Composite]    DateTimeCreated                : 2024:07:17 02:35:31
[Composite]    DigitalCreationDateTime        : 1846:05:15 11:52:58
[Composite]    GPSDateTime                    : 2018:05:20 00:05:36Z
[Composite]    SubSecCreateDate                : 1846:05:15 11:52:58-08:00
[Composite]    SubSecDateTimeOriginal          : 1846:05:15 11:52:58-08:00
[Composite]    SubSecModifyDate                : 1972:01:01 00:00:00-07:00
[ExifIFD]      CreateDate                      : 1846:05:15 11:52:58
[ExifIFD]      DateTimeOriginal                : 1846:05:15 11:52:58
[ICC-header]    ProfileDateTime                : 2016:01:01 00:00:00
[IFD0]          ModifyDate                      : 1972:01:01 00:00:00
[IPTC]          DateCreated                    : 1846:05:15
[IPTC]          DigitalCreationDate            : 1846:05:15
[QuickTime]    CreateDate                      : 2024:08:28 06:04:30
[System]        FileAccessDate                  : 2024:08:27 23:04:30-07:00
[System]        FileInodeChangeDate            : 2024:08:28 16:18:44-07:00
[System]        FileModifyDate                  : 2004:11:15 12:01:11-08:00
[Track1]        MediaCreateDate                : 2024:08:28 06:04:30
[Track1]        TrackCreateDate                : 2024:08:28 06:04:30
[Track2]        MediaCreateDate                : 2024:08:28 06:04:30
[Track2]        TrackCreateDate                : 2024:08:28 06:04:30
[Track3]        MediaCreateDate                : 2024:08:28 06:04:30
[Track3]        TrackCreateDate                : 2024:08:28 06:04:30
[Track4]        MediaCreateDate                : 2024:08:28 06:04:30
[Track4]        MediaModifyDate                : 2024:08:28 06:05:55
[Track4]        TrackCreateDate                : 2024:08:28 06:04:30
[Track4]        TrackModifyDate                : 2024:08:28 06:05:55
[UserData]      DateTimeOriginal                : 2015:11:08 00:00:00-08:00
[XMP-exif]      DateTimeOriginal                : 2015:11:08 00:00:00
[XMP-photoshop] DateCreated                    : 1846:05:15 11:52:58
[XMP-xmp]      CreateDate                      : 1846:05:15 11:52:58
[XMP-xmp]      ModifyDate                      : 1972:01:01 00:00:00

Now looking at this can you guide me further concerning which 'dates' I should add to me configuration file. I ask because you mentioned something about not using XMP group and also because I see some dates showing 1800's. I would presume that I should not use these configuration file.

Ken Lind

klind

OK, I'm confused...

All I did was add some additional data to search for and now it won't run.

Here's the code:

```
%Image::ExifTool::UserDefined = (
   'Image::ExifTool::Composite' => {
      MyDate => {
         Desire => {
            0 => 'Composite:DateTimeCreated',
            1 => 'Composite:GPSDateTime',
            2 => 'Composite:SubSecModifyDate',
            3 => 'Exif:CreateDate',
            4 => 'Exif:DateTimeOriginal',
            5 => 'Exif:ModifyDate',
            6 => 'GPS:GPSDateStamp',
            7 => 'IFD0:ModifyDate',
            8 => 'IPTC:DateCreated',
            9 => 'IPTC:DigitalCreationDate'
            10 => 'System:FileAccessDate',
            11 => 'System:FileInodeChangeDate',
            12 => 'System:FileModifyDate',
            13 => 'Track1:MediaCreateDate',/usr/local/bin/MyExiftool-00.config
            14 => 'Track1:TrackCreateDate',
            15 => 'Track2:MediaCreateDate',
            16 => 'Track2:TrackCreateDate',
            17 => 'Track3:MediaCreateDate',
            18 => 'Track3:TrackCreateDate',
            19 => 'Track4:MediaCreateDate',/usr/local/bin/MyExiftool-00.config
            20 => 'Track4:MediaModifyDate',
            21 => 'Track4:TrackCreateDate',
            22 => 'Track4:TrackModifyDate',
            23 => 'XMP:CreateDate'
            24 => 'XMP:DateCreated',
            25 => 'XMP:DateTimeDigitized',
            26 => 'XMP:DateTimeOriginal',
            27 => 'XMP:ModifyDate',
         },
         ValueConv => q{
            my ($earliest) = (sort {$a cmp $b} grep $_, @val)[0];
            return $earliest;
         },
         PrintConv => '$self->ConvertDateTime($val)',
      },
   },
);
```

When run I get 'Warning: [minor] Tag 'mydate' not defined - {filename}

Ken Lind

Phil Harvey

You have some spurious "/usr/local/bin/MyExiftool-00.config" strings in this file.

Also, a couple of lines are missing commas at the end.

You should get a compiler warning due to these syntax problems when the config file is loaded.

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

StarGeek

Quote from: Kenneth on August 30, 2024, 01:32:58 AMA question: While what I want to discern is the earliest date in the meta data, I notice that your command searches for 'time'. I learned from this and found it interesting. I never would have thunk to search for 'time' when I want to know about dates...

Time is a group 2 name -G2. Other than Time and Preview, they aren't commonly used. You can find the full list under the GetAllGroups function.

QuoteI ask because you mentioned something about not using XMP group

I hope I didn't say that. There are some XMP groups to ignore like the XMP-xmpMM group, and I wouldn't necessarily trust the ones that are specific to certain programs, such XMP-acdsee or XMP-Microsoft, but they should otherwise be good.

The reason I don't trust XMP-Microsoft is because I'm going through my sisters collection of images from years ago. She used Windows Live Photo Gallery and it was really bad when it came to dates.

Quotealso because I see some dates showing 1800's. I would presume that I should not use these configuration file.

I wonder what program was used to mess up the dates so bad as to place them in the 1800s. Change this part of the code to remove all entries before a specific date. In this example, any date before January 1, 1970 will be removed. Adjust 1970 to your minimum desired year. (I have not tested this, but I think it should work)
         ValueConv => q{
            my @CleanArray = grep { $_ gt '1970' } @val;
            my ($earliest) = (sort {$a cmp $b} grep $_, @CleanArray)[0];
            return $earliest;
         },

Some other notes. I would absolutely drop System:FileAccessDate. This is changed every time the file is touched and is otherwise useless. I would also drop all the Track timestamps. There are a lot of video programs that don't save any metadata, but if the program is good enough to write the Track time stamp, then it is almost certainly writing the Quicktime:CreateDate (which probably should be in your list). You might also add Quicktime:DateTimeOriginal and Quicktime:CreationDate.

You will find that some Quicktime time stamps will appear as 0000:00:00 00:00:00 (or in 1903/1904 if the -api QuickTimeUTC option is used). The above change to the code will filter these out.

Note, it is very important that you keep the group name simple (Group 0) for Quicktime tags, because Quicktime data is such a mess and the same tag can appear in three different subgroups. It can get worse in the case of some tags, as they can then also appear multiple times in the same subgroup. For example, Description can appear in three different places in the Quicktime ItemList subgroup. The only way to write different ones is through the Group 7 Tag ID.

* 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).

StarGeek

Oh yeah, another one to ignore. Any timestamp that's part of the ICC_Profile, such as ProfileDateTime. These are static and indicate when that profile was created. You'll often see some that were created in the 90s.
* 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).

klind

#7
Thanx Phil... I was doing some copy/paste and those two long lines are not in the configuration file that I actually use. The missing comas though is an oversight on my part. I fixed that. Thanx for pointing that out to me!

Thanx StarGeek... I'm learning tons from you. Do you do brain dumps? ... Ha-ha.I cleaned up the configuration file to add the two missing comas and change the search per your suggestions and it is working fine now. Here's a look at my new configuration file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyDate => {
            Desire => {
                0 => 'Composite:DateTimeCreated',
                1 => 'Composite:GPSDateTime',
                2 => 'Composite:SubSecModifyDate',
                3 => 'Exif:CreateDate',
                4 => 'Exif:DateTimeOriginal',
                5 => 'Exif:ModifyDate',
                6 => 'GPS:GPSDateStamp',
                7 => 'IFD0:ModifyDate',
                8 => 'IPTC:DateCreated',
                9 => 'IPTC:DigitalCreationDate',
                10 => 'Quicktime:CreateDate',
                11 => 'Quicktime:CreationDate',
                12 => 'Quicktime:DateTimeOriginal',
                13 => 'System:FileInodeChangeDate',
                14 => 'System:FileModifyDate',
                15 => 'XMP:CreateDate',
                16 => 'XMP:DateCreated',
                17 => 'XMP:DateTimeDigitized',
                18 => 'XMP:DateTimeOriginal',
                19 => 'XMP:ModifyDate',
            },
            ValueConv => q{
                my @CleanArray = grep { $_ gt '1970' } @val;
                my ($earliest) = (sort {$a cmp $b} grep $_, @CleanArray)
[o];
                return $earliest;
            },
            PrintConv => '$self->ConvertDateTime($val)',
        },
    },
);

Thanx to both of you.

Ken (aka Paxapunch at the poker tables)





Ken Lind

StarGeek

Brain dump is a new term for me and searching for a definition, I can't find an explanation that doesn't seem to me to be different from taking notes. And it seems to be hated in IT.

I take a lot of notes about exiftool on obscure but useful procedures and on frequently asked question. I've been condensing them lately and started saving them on GitHub, though it is still in a very raw state.
* 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).