post processing and "set creation date" for dates before 1970

Support for macOS users
Post Reply
cheaters
Posts: 221
Joined: 09 Oct 2016, 02:01

post processing and "set creation date" for dates before 1970

Post by cheaters »

Hi Red,

I am using macOS

I have the post processing option set to "set creation date" and I have a lot of older films... pre 1970.

I am getting crazy date stamps on those files because Unix doesn't allow dates to be set before 1/1/1970.

Image

:!: :?: Is there any coding you can do for Unix/macOS so the episodes/movie release dates prior to "January 1, 1970" have modified dates of "January 1, 1970" instead of random dates in the year 2200?


From exiftool Phil
*Note that depending on your system you may or may not have success setting filesystem times to a date before 1970.
- Phil
User avatar
rednoah
The Source
Posts: 23922
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: post processing and "set creation date" for dates before 1970

Post by rednoah »

macOS / APFS do not fundamentally disallow dates before 1970 on the file system level at the very least:

Console Output: Select all

$ touch -d 1968-01-0100:00:00 a.txt
$ stat -x a.txt
...
Access: Mon Jan  1 00:00:00 1968
Modify: Mon Jan  1 00:00:00 1968
Change: Fri Aug 16 03:30:00 2024
 Birth: Fri Aug 16 03:30:00 2024


:!: But if you're using a Linux-based NAS that you access from macOS, then anything is possible. Depending on your software configuration, what you want may or may not be possible due to software compatibility issues.



:!: Notably, macOS does have a dedicated "file creation date" and "last-modified date" fields. Linux does not, and so on Linux, setting one may also set the other and vice versa. That can be confusing. On top of that, if you're using a remote file system, then there's gonna be another layer of translation where things can go awry. That's probably where the 2262 dates are introduced, as signed integer negative time stamps are misinterpreted as unsigned integer positive time stamps at some point.





EDIT:

:!: :!: :!: Adding to the confusion, even local macOS / APFS may behave inconsistently when dates before 1970 are at play, i.e. setting Last-Modified may or may not also set Creation-Date implicitly depending on the dates at play:

Console Output: Select all

$ stat -x 2*
  File: "2001 - A Space Odyssey (1968).mkv"
...
Modify: Tue Apr  2 00:00:00 1968
 Birth: Tue Apr  2 00:00:00 1968

$ touch -d 1980-01-0100:00:00 2*
$ stat -x 2*
  File: "2001 - A Space Odyssey (1968).mkv"
...
Modify: Tue Jan  1 00:00:00 1980
 Birth: Tue Jan  1 00:00:00 1980

$ touch -d 1940-01-0100:00:00 2*
$ stat -x 2*
  File: "2001 - A Space Odyssey (1968).mkv"
...
Modify: Mon Jan  1 00:00:00 1940
 Birth: Tue Jan  1 00:00:00 1980
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23922
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: post processing and "set creation date" for dates before 1970

Post by rednoah »

cheaters wrote: 16 Aug 2024, 00:51 :!: :?: Is there any coding you can do for Unix/macOS so the episodes/movie release dates prior to "January 1, 1970" have modified dates of "January 1, 1970" instead of random dates in the year 2200?
We could certainly have a Custom Post-Processing Script that does what you need to do in your specific environment with your specific set of limitations:

Groovy: Select all

{ source, target ->
	if (d.timeStamp > 0) {
		system 'touch', '-m', '-d', "${d}T00:00:00", target
	} else {
		system 'touch', '-m', '-d', "1970-01-01T00:00:00", target
	}
}
NOTE: The touch command only updates the Last-Modified-Date and does not change the File-Creation-Date
:idea: Please read the FAQ and How to Request Help.
cheaters
Posts: 221
Joined: 09 Oct 2016, 02:01

Re: post processing and "set creation date" for dates before 1970

Post by cheaters »

rednoah wrote: 16 Aug 2024, 03:43 macOS / APFS do not fundamentally disallow dates before 1970 on the file system level at the very least:

Console Output: Select all

$ touch -d 1968-01-0100:00:00 a.txt
$ stat -x a.txt
...
Access: Mon Jan  1 00:00:00 1968
Modify: Mon Jan  1 00:00:00 1968
Change: Fri Aug 16 03:30:00 2024
 Birth: Fri Aug 16 03:30:00 2024
... On top of that, if you're using a remote file system, then there's gonna be another layer of translation where things can go awry. That's probably where the 2262 dates are introduced, as signed integer negative time stamps are misinterpreted as unsigned integer positive time stamps at some point.
I am saving to a network HDD that is hosted by a MacMini running the same version of macOS as my desktop.

:arrow: I wanted to test your theory. I tried the commands remotely and there was no change to the file's Date Modified. I tried them on the MacMini hosting the HDD and the file's Date Modified was indeed changed to 1957!
Post Reply