Strange: Incorrect modification time (seconds) of a copyed file Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
newbieforever
Posts: 400
Joined: 24 Aug 2016, 03:34

Strange: Incorrect modification time (seconds) of a copyed file

02 Dec 2017, 14:18

Is this a known issue? When a file is copyed to another drive, the modification time is changed slightly (1 or 2 seconds).

I can reproduce this with the following demo script. Drive D in my case is a USB stick.

Code: Select all

   FileAppend, , C:\Test\TestFile

   FileCopy, C:\Test\TestFile, D:\Test\TestFileX, 1

   FileGetTime, TS1, C:\Test\TestFile
   FileGetTime, TS2, D:\Test\TestFileX

   If !(TS1 = TS2)
      MsgBox %TS1%`r`n%TS2%

   FileDelete, C:\Test\TestFile
Last edited by newbieforever on 02 Dec 2017, 15:35, edited 1 time in total.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Strange: Incorrect modification time (seconds) of a copyed file  Topic is solved

02 Dec 2017, 15:43

This is very interesting, thanks for sharing.

This link looks relevant.
c# - Why does File Modified Time automatically increase by 2 seconds when copied to USB? - Stack Overflow
https://stackoverflow.com/questions/115 ... opied-to-u

I'd had problems a bit like this in the past, and found nothing about it, and even posted to Stack Overflow about it, no-one provided any answers, and the question was eventually deleted due to inactivity.

So if you experiment, does the number always increase by 1 or 2 seconds, and to an even number?

And when you copy from USB to PC, I suppose that no changes occur that way round.

A solution might be to place the files into an archive, although I understand that this would not be ideal. Or to store the UTC datestamps into a text file. If you use UTC datestamps, there is no ambiguity about when the files were created.

Is the USB stick very old? Perhaps older USB sticks use FAT, and newer USB sticks use NTFS? If you go to My Computer (aka Computer) and check the properties for the drive, is it FAT?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
newbieforever
Posts: 400
Joined: 24 Aug 2016, 03:34

Re: Strange: Incorrect modification time (seconds) of a copyed file

02 Dec 2017, 16:29

@jeesweg:
I THANK YOU SO MUCH!!!

FAT has a 2 sec timestamp granularity!

Now I am able to solve my problem: When comparing two timestamps, instead of If (TS1 = TS2) I use now If (Abs(TS1 - TS2) < 3) to identify that the files have the same modification date.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], KilliK, TAC109, tallguyyo and 220 guests