ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: Paul Barrett on September 27, 2016, 02:15:53 PM

Title: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 27, 2016, 02:15:53 PM
Win 10 Home on 64 bit Intel system
Exiftool version 10.11

Expectation: Change File Modified date to match Date/Time Original. 

Problem: Dates in the range 1904 - 1925 are incorrectly updated to 2014 -2025  Later dates are OK and I have done many of them from 1930 through to 1970.  I don't have images for all years so don't know where the tipping is exactly.

Command line:
exiftool "-FileModifyDate<DateTimeOriginal" "-modifydate<DateTimeOriginal" "\\nas02\photo\pictures\1920"

This command was supplied by someone else but was successful on several test subjects from later years.

Sample Result:

Source Data:
---- EXIF ----
Date/Time Original               1920:06:30 00:00:01

Target
---- File ----
File Name                        Great Uncle Harry 1.jpg
Directory                        //nas02/photo/Pictures/1920
File Size                        390 kB
File Modification Date/Time      2020:06:30 00:00:01+01:00

I hope I have provided you with enough information.

Kind Regards

Paul Barrett (newbie)

Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 27, 2016, 02:29:36 PM
Hi Paul,

ExifTool uses the standard C library functions for date/time which are typically limited to the range 1970 to 2034.

Also, you are trying to set a filesystem date/time, and some filesystems have similar limitations.  So even if ExifTool did its own date calculations, you may still be out of luck depending on what filesystem you are using.

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: StarGeek on September 27, 2016, 02:48:03 PM
This actually isn't an error with exiftool, it's has to do with the underlying OS.  You're trying to set the file modify date to a time when there wasn't even computers.  Basically, you can't set any of the FILE timestamps to dates before 1970, because most (all?) computer time is based upon Unix time (https://en.wikipedia.org/wiki/Unix_time), which starts January 1st, 1970.  If you try to set the timestamp to a time before that, you have an integer underflow, basically trying to set it to a negative number and since timestamps are unsigned, you end up with a future date.

Here's a video that can help explain it:
Why 1/1/1970 Bricks Your iPhone (https://www.youtube.com/watch?v=MVI87HzfskQ)

Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 27, 2016, 05:19:13 PM
Thank you guys, especially for the rapid response, and I get what you are saying.  To sort out the problem is there a way I can assign a specific date from a text string so I can at least get us back from the future?  ;D

I am a complete newbie on exif tool though it looks fabulous

- Paul

PS From what you said about 2034 being the date limit, I guess that explains these error messages with their 2040 date :)

Warning: Cannot handle date (01, 00, 00, 30, 5, 2040) in File:FileModifyDate (ValueConvInv) - //nas02/photo/pictures/1940/Great Uncle Harry 2.jpg
Warning: Cannot handle date (01, 00, 00, 30, 5, 2040) in File:FileModifyDate (ValueConvInv) - //nas02/photo/pictures/1940/Grandma Beatrice Barrett.jpg
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 27, 2016, 05:57:42 PM
You can write a specific date like this:

exiftool -filemodifydate="2016:09:27 17:55:00" FILE

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 27, 2016, 06:13:26 PM
>You can write a specific date like this:

>exiftool -filemodifydate="2016:09:27 17:55:00" FILE

>- Phil

Hi Phil

Great - can I substitute FILE with DIR to run it over all images in a folder?

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: StarGeek on September 27, 2016, 07:35:28 PM
Quote from: Paul Barrett on September 27, 2016, 06:13:26 PM
Great - can I substitute FILE with DIR to run it over all images in a folder?

Yes you can.
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 04:02:35 AM
Excellent

And if it's possible, how do I make the DIR string apply to a folder and all its subfolders please?

Regards

Paul

PS This a great forum - so responsive
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Hayo Baan on September 28, 2016, 06:47:06 AM
Just add the option -r to your exiftool command  :)
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 07:11:44 AM
Excellent - this just gets better and better.  ;D ;D ;D ;D
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 08:38:57 AM
Next question.  Is there a way to tell exif tool not to update the file modified date when executing other metadata actions please?

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 28, 2016, 08:41:54 AM
Hi Paul,

This is the -P option.  The application documentation (https://exiftool.org/exiftool_pod.html) explains all this and more...

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 09:07:00 AM
Thanks Phil

Don't know why I hadn't found that doc in my searching. Must've had a senior moment  :-[

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 28, 2016, 09:52:12 AM
Hi Paul,

You can also see the same documentation by running exiftool with no arguments.  The link I gave you above is just an HTML translation of this built-in documentation.

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 10:27:26 AM
Thank you

Pointing me at the manual is a bit of a double-edged sword because it just encourages me to do other things and then screw up some more!  ;D

For example, as expected after all the updates I have been doing, I now have a large number of JPG_ORIGINAL files, which I wanted to tidy up.

I started small, on just one file and tried this:

exiftool -delete_original \\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg

As I had not used the ! parameter I expected to get a prompt before deletion.  Instead the command returned this:

    1 image files found
    0 original files found

But I can see the file in Explorer.  I tried running the command on the parent folder with the -r switch in case I had specified the file name incorrectly.  I got exactly the same answer, despite the fact that there are 4 sub folders and 271 files.

It's probably rookie error as usual.  I have stared at this till my eyes have gone square but I cannot see where I have screwed up.

Help please!

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 28, 2016, 10:31:30 AM
Hi Paul,

Quote from: Paul Barrett on September 28, 2016, 10:27:26 AM
exiftool -delete_original \\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg

That command should work provided the following file exists:

\\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg_original

What does this command give?:

dir \\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg_original

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 10:51:37 AM
It gives:

C:\Windows\ExifTool>dir \\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg_original
The system cannot find the file specified.

But that's just not right.  I can see the file in Explorer.  In fact I can see all 4,672 jpg_original files

Hm.  I think a PC reboot may be required since the command line won't even let me switch to the mapped drive y: - perhaps that's the cause of the issue.  I will reboot and let you know...

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 28, 2016, 10:56:53 AM
Could the problem be the leading double backslashes?  I'm not familiar with that syntax.

Maybe something like this would work?:

dir y:\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg_original

And if so, the exiftool command should be:

exiftool -delete_original y:\nas02\photo\pictures\2000-04\2000-04-01_0001.jpg

or this to delete them all:

exiftool -delete_original -r y:\nas02\photo\pictures\

but you should be sure your updates are good, or have backups before deleting all of the originals.

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 11:14:49 AM
\\ is the UNC pathname prefix for networked drives

OK so the problem is some sort of permissions issue.  When I ran cmd as admin I could not switch to network drives.  I started a normal cmd session and, with my regular user credentials, I was able to switch to the y: drive and to the specific directory where the files are located.  There I did a dir listing and there's the file

Directory of Y:\Pictures\2000\2000-04
24/09/2016  15:24         1,726,555 2000-04-01_0001.jpg_original


I am flummoxed.  All the permutations of the delete originals command are failing, regardless of whether I run cmd as admin or not, yet all the commands that created them in the first place worked flawlessly.

Is there any reason why I should not just delete them in explorer?

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Phil Harvey on September 28, 2016, 11:17:25 AM
Hi Paul,

Just go ahead and delete them in Explorer then.

I can't explain or reproduce the problem you are seeing.

- Phil
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 12:03:11 PM
OK - let's just put this one in the NFI bucket

I will delete them in explorer.  I have backups with history running on these folders so I will have a fallback for 6 months.

Thanks for your help!

- Paul
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: StarGeek on September 28, 2016, 02:42:46 PM
When you have your command setup how you like it, you can add -overwrite_original to the command to skip the creation of the "_original" backup files.
Title: Re: Date Handling Problem on dates in the region of c.1904 c1925
Post by: Paul Barrett on September 28, 2016, 04:54:23 PM
Perfect.  Done!

- Paul