Invalid date/time and No writable tags

Started by Marina, February 01, 2024, 06:27:52 PM

Previous topic - Next topic

Marina

Hello everyone, I'm using ExifTool to find the earliest date of an image file and set all dates to that value. I use this config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        # Select oldest date from a number of date tags
        OldestDateTime => {
            Desire => {
                0 => 'FileModifyDate',
                1 => 'MDItemFSContentChangeDate',
                2 => 'FileCreateDate',
                3 => 'MDItemFSCreationDate',
                4 => 'ModifyDate',
                5 => 'CreateDate',
                6 => 'DateTimeCreated',
                7 => 'DateTimeOriginal',
                8 => 'SubSecTimeOriginal',
                9 => 'SubSecTimeDigitized',
                10 => 'SubSecCreateDate',
                11 => 'SubSecDateTimeOriginal',
            },
            ValueConv => q{
                my $oldest = undef;
                for my $date (@val) {
                    next if not defined $date or $date lt '1970:01:02';
                    $date =~ s/[+-]\d{2}:\d{2}$//; # Strip TimeZone
                    if ($date && (!$oldest || $date lt $oldest)) {
                        $oldest = $date;
                    }
                }
                return $oldest;
            },
        },
    },
);

1;

This is the command I use:
exiftool -config C:\Windows\oldest_datetime.config "C:\Users\Utente\Documents\Foto e video" -r "-FileModifyDate<OldestDateTime" "-FileCreateDate<OldestDateTime" "-ModifyDate<OldestDateTime" "-CreateDate<OldestDateTime" "-DateTimeOriginal<OldestDateTime" "-DateAcquired<OldestDateTime" "-SubSecCreateDate<OldestDateTime" "-SubSecDateTimeOriginal<OldestDateTime"

This is the warning I get for quite a lot of files:
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in File:FileModifyDate (PrintConvInv) - C:/Users/Utente/Documents/Foto e video/20231010_103701.jpg
Warning: No writable tags set from C:/Users/Utente/Documents/Foto e video/20231010_103701.jpg


When I check the files' properties the format looks good to me though:
exiftool -a -s -G1 -time:all "C:/Users/Utente/Documents/Foto e video/20231010_103701.jpg"
[System]        FileModifyDate                  : 2023:08:09 13:00:43+02:00
[System]        FileAccessDate                  : 2024:02:01 23:52:19+01:00
[System]        FileCreateDate                  : 2024:01:30 09:39:33+01:00
[IFD0]          ModifyDate                      : 2023:08:09 13:00:42
[ExifIFD]       DateTimeOriginal                : 2023:08:09 13:00:42
[ExifIFD]       CreateDate                      : 2023:08:09 13:00:42
[ExifIFD]       OffsetTime                      : +02:00
[ExifIFD]       OffsetTimeOriginal              : +02:00
[ExifIFD]       SubSecTime                      : 177
[ExifIFD]       SubSecTimeOriginal              : 177
[ExifIFD]       SubSecTimeDigitized             : 177
[ICC-header]    ProfileDateTime                 : 2022:07:01 00:00:00
[Samsung]       TimeStamp                       : 2023:08:09 13:00:42.177+02:00
[Composite]     SubSecCreateDate                : 2023:08:09 13:00:42.177
[Composite]     SubSecDateTimeOriginal          : 2023:08:09 13:00:42.177+02:00
[Composite]     SubSecModifyDate                : 2023:08:09 13:00:42.177+02:00


I don't understand what's wrong with FileModifyDate format.. can somebody help?

Phil Harvey

The problem is with the value you are copying to FileModifyDate.  What is the value of OldestDateTime for this 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 ($).

Marina

Oh I get it! In fact now I ran
exiftool -config C:\Windows\oldest_datetime.config -u -g1 "C:/Users/Utente/Documents/Foto e video/20231010_103701.jpg"

And the last value extracted was:
Oldest Date Time                : 177

In my config file (which I edited in my original post because some lines were missing) I included SubSecTimeOriginal and SubSecTimeDigitized to check for the oldest date but I guess they're the culprits for my warning.

I was wondering though, is there a way to edit my config file to ignore a value if it's not in a specific format?

Phil Harvey

Try this:

                for my $date (@val) {
                    next if not defined $date or $date lt '1970:01:02';
                    next if $date !~ /^\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}/;
                    $date =~ s/[+-]\d{2}:\d{2}$//; # Strip TimeZone
                    if ($date && (!$oldest || $date lt $oldest)) {
                        $oldest = $date;
                    }
                }

- 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

I would say it would be easier to simply remove those lines, as those tags by themselves would never be a complete date.  You also should removed the MDItemFSContentChangeDate and MDItemFSCreationDate tags as they are Mac only tags and don't exist on Windows.
* 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).