New Command to Update a File Timestamp

Feb 12, 2016
7
0
68
You should create a new command to update one or more of a file's timestamps. The default behavior (without any command qualifiers) should be to make sure that the file's Create Timestamp is no later than the file's Update Timestamp. I have numerous files where for some unknown reason the Create Timestamp is much later than the Modify Timestamp, sometimes many years later. Obviously, such a situation is absurd. I should be able to easily change the Create Timestamp so that it is the same as or earlier than the Modify Timestamp.

I don't have a specific name for this command that I consider to be particularly good. However, either UPDATE or TIMESTAMP come to mind. I am open to good alternatives. One alternative is to enhance the TOUCH command to allow the user to set the Modification Timestamp to be less than or equal to the Creation Timestamp for all files in a single directory or an entire directory tree.

What I want is a simple way to specify the following without having to write my own program:
Create_Timestamp = Modification_Timestamp +/- Delta_Time
where Delta_Time is specified as a combination of date and time that is either added to or subtracted from the Modification_Timestamp.
If the sign is +, then the Creation_Timestamp is later than the Modification_Timestamp, i.e., Delta_Time is added to Modification_Timestamp.
If the sign is -, then the Creation_Timestamp is earlier than the Modification_Timestamp, i.e., Delta_Time is subtracted from Modification_Timestamp.
 
Last edited:
Feb 12, 2016
7
0
68
Have you looked at the TOUCH command?
Yes. It has a lot of abilities but it does not have the ability to set the creation date to be less than or equal to the modification date for all files in a single directory or an entire directory tree. One possibility of implementing what I want is to add this capability to the TOUCH command.
 
May 20, 2008
12,175
133
Syracuse, NY, USA
It's easy to get a file a file whose creation date is later than the modified date. Just COPY or MOVE a file to a destination where it doesn't already exist. That's standard procedure. Expect it to happen if you're archiving files.

Code:
v:\> del .ses
Deleting V:\.ses
     1 file deleted

v:\> copy Z:\.ses v:\
Z:\.ses => V:\.ses
     1 file copied

v:\> filetimes z:\.ses
Created:  2021-12-03 13:28:55
Accessed: 2021-12-04 16:36:24
Modified: 2021-12-04 16:28:57

v:\> filetimes v:\.ses
Created:  2021-12-04 16:36:24 <--- later than modified
Accessed: 2021-12-04 16:36:24
Modified: 2021-12-04 16:28:57

And it's fairly easy to change the creation date/time to the modified date/time if the former is later than the latter for a collection of files. [Below, change the file specification to do the files of your choice. I did only one.]

Code:
v:\> do f in /a:-d .ses (if %@fileage["%f",c] GT %@fileage["%f",w] touch /Dc%@filedate["%f",w] /Tc%@filetime["%f",w,s] "%f" )
2021-12-04 16:28:57.000  V:\.ses

v:\> filetimes v:\.ses
Created:  2021-12-04 16:28:57
Accessed: 2021-12-04 16:36:24
Modified: 2021-12-04 16:28:57

I haven't tried it but you could probably do that for a whole tree by specifying "/S" in the DO command.

Be careful using TOUCH. Test it first using the "/N" (do nothing) option. And don't a space between "/Dc" ["/Tc"] and the date [time]. Doing that cost me half an hour!

FILETIMES is a plugin command.
 

Similar threads