Setting FileModifyDate with sub second precision

Started by snoukkis, May 11, 2020, 04:29:17 PM

Previous topic - Next topic

snoukkis

Hi,

I have a shared Dropbox folder with images and videos named with many formats by different people. I'd like to view them in shooting time order, but I don't want to modify other peoples files. So no renaming.

However it's ok to modify the file modification time in file system. I need to do it with millisecond precision though because some images are shot close together in burst mode.

SubSecDateTimeOriginal tag seems to have what I need:
> exiftool 2020-05-07-13-52-04-0015.CR2 -SubSecDateTimeOriginal
Date/Time Original              : 2020:05:07 13:52:04.92

I tried to set it to FileModifyDate:
exiftool "-FileModifyDate<SubSecDateTimeOriginal" .

The problem is that it's not setting the millisecond part:
> stat 2020-05-07-13-52-04-0015.CR2
  File: 2020-05-07-13-52-04-0015.CR2
...
Modify: 2020-05-07 13:52:04.000000000 +0300


Bummer. Any ideas what might be going wrong?

Phil Harvey

Interesting.

1. I have no idea how to set the millisecond time of a file.

2. This feature would be very dependent on the operating system used.

3. What operating system are you running?

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

snoukkis

Quote from: Phil Harvey on May 11, 2020, 09:48:41 PM
3. What operating system are you running?

Hi,

In this case I'm using Mac OS Mojave and APFS.
If you think I'd need other combinations:

  • I also have an external exFAT SSD.
  • I also have another machine with both Windows+NTFS and Linux+Ext4 installed (though Windows just overwrote my UEFI load sequence for Linux, so I'd have to fix that with a live USB first).
Though I don't think APFS has problems with sub second timestamps. Let me attach the full stat:
> gstat 2020-05-07-13-52-04-0015.CR2
  File: 2020-05-07-13-52-04-0015.CR2
  Size: 36209448  Blocks: 72480      IO Block: 4096   regular file
Device: 1000004h/16777220d Inode: 14626216    Links: 1
Access: (0777/-rwxrwxrwx)  Uid: (  501/     snoukkis)   Gid: (   20/   staff)
Access: 2020-05-11 23:34:43.417273601 +0300
Modify: 2020-05-07 13:52:04.000000000 +0300
Change: 2020-05-11 22:46:42.577343198 +0300
Birth: 2020-05-07 13:52:04.000000000 +0300


Note the Access and Change stats have sub second time set.

Any help would be appreciated. I'm in charge of two small kids atm., so I don't have the time to learn Perl to delve into the source code unfortunately. :/ In another life I wouldn't mind contributing to as useful tools as this.

Phil Harvey

I think you would have to find some utility that writes sub-second file timestamps.  ExifTool uses the standard Perl utilities for all timestamps except FileCreateDate, and these utilities accept only integer seconds.  On MacOS, ExifTool uses the Apple developer "setfile" utility to write FileCreateDate, but as far as I can tell this doesn't allow subseconds either.

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

snoukkis

Quote from: Phil Harvey on May 12, 2020, 07:15:17 AM
these utilities accept only integer seconds

I see. That's unfortunate.

I did a test:

> touch test.txt
> echo "foobar" >> test.txt
> gstat test.txt


  File: test.txt
  Size: 7          Blocks: 8          IO Block: 4096   regular file
Device: 1000004h/16777220d Inode: 14683518    Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/     uku)   Gid: (   20/   staff)
Access: 2020-05-13 23:19:49.204378673 +0300
Modify: 2020-05-13 23:19:48.189696107 +0300
Change: 2020-05-13 23:19:48.189696107 +0300
Birth: 2020-05-13 23:19:33.616897172 +0300


Clearly sub-second file timestamps are supported. No idea how to set them though. :/

snoukkis

I tested this: https://stackoverflow.com/questions/55469653/how-to-set-creation-date-time-with-milliseconds-to-file

(the g-prefixes on touch and stat mean they are the coreutils versions from brew)

> gtouch --date '01/23/2000 12:00:00.099' test.txt
> gstat test.txt


  File: test.txt
  Size: 7          Blocks: 8          IO Block: 4096   regular file
Device: 1000004h/16777220d Inode: 14683518    Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/     uku)   Gid: (   20/   staff)
Access: 2020-05-13 23:37:15.029964650 +0300
Modify: 2000-01-23 12:00:00.099000000 +0200
Change: 2020-05-13 23:37:13.851873436 +0300
Birth: 2000-01-23 12:00:00.099000000 +0200


That worked. Granted, it's not exactly a generic solution. :P