I suppose this is just a curiosity, as it occurs in both TCmd and the Windows command shell.
The creation timestamp of a file persists across deletion and re-creation of the file.
Note that the create date is the one previously assigned to the file.
This date will persist through numerous deletions and creations, and across multiple TCC windows in TCmd.
The create-date will be reset only when the file is deleted AND TCmd is shut down and relaunched.
This behavior is also present in the Windows command shell.
Given only the above test, this could also be construed as a possible failure in the @filedate/@filetime functions.
But it's not: the same timestamps show up in Windows File Explorer.
The creation timestamp of a file persists across deletion and re-creation of the file.
Code:
[C:\batch]type create-date-problem.btm
@ echo off
:: Please start this test with a new file that has not been created
:: AT ANY TIME within this TCmd session.
:: Run it again, if you want, with the same filename.
set fname=%1
echo foo > %fname
echo File %fname as originally created:
gosub SHOW %fname
echo.
echo File %fname after repeated deletion and recreation:
do 5
del %fname >& NUL
echo foo > %fname
gosub SHOW %fname
pause /w3 /c /t Pausing 3 seconds...
enddo
quit
:SHOW [file]
echos w: %@filedate[%file,w,4] %@filetime[%file,w,s]
echos c: %@filedate[%file,c,4] %@filetime[%file,c,s]
echo a: %@filedate[%file,a,4] %@filetime[%file,a,s]
return
Code:
[C:\batch]create-date-problem FILEA
File FILEA as originally created:
w: 2021-11-17 04:43:12 c: 2021-11-17 04:43:12 a: 2021-11-17 04:43:12
File FILEA after repeated deletion and recreation:
w: 2021-11-17 04:43:12 c: 2021-11-17 04:43:12 a: 2021-11-17 04:43:12
w: 2021-11-17 04:43:15 c: 2021-11-17 04:43:12 a: 2021-11-17 04:43:15
w: 2021-11-17 04:43:18 c: 2021-11-17 04:43:12 a: 2021-11-17 04:43:18
w: 2021-11-17 04:43:21 c: 2021-11-17 04:43:12 a: 2021-11-17 04:43:21
w: 2021-11-17 04:43:24 c: 2021-11-17 04:43:12 a: 2021-11-17 04:43:24
This date will persist through numerous deletions and creations, and across multiple TCC windows in TCmd.
The create-date will be reset only when the file is deleted AND TCmd is shut down and relaunched.
This behavior is also present in the Windows command shell.
Given only the above test, this could also be construed as a possible failure in the @filedate/@filetime functions.
But it's not: the same timestamps show up in Windows File Explorer.