TOUCH – Windows CMD Command

Chance file timestamps

This is a POSIX utility.
Use the optional argument /t to specify a date other than the current time.
( four-digit years, two-digit months, days, hours, minutes, seconds)

An alternative Touch using the COPY command

As first documented in the ancient (MSDOS) KB article Q69581 the COPY /b command can be used to touch the date/time of a file:

This takes a source file, adds nothing (represented by the commas) and copies it to the same file as a destination. If you are working in a single folder, the second filename can be omitted as it will default to writing the same filename.

There are a few caveats with this technique:

It fails for read-only or hidden files. It may reset file permissions back to the default for the folder.

In some versions of Windows, if the file is 0 bytes long it will be deleted! If the file is a binary file with trailing null characters (0x00), they will be deleted, corrupting the file.

It is no longer a documented option in current versions of Windows. A better alternative is PowerShell, you can call a one-liner with powershell.exe


You may also like...

1 Response

  1. froleprotrem says:

    A lot of thanks for all of your labor on this website. Gloria enjoys going through investigations and it’s really simple to grasp why. Most people learn all relating to the lively ways you make invaluable suggestions via the web site and therefore improve contribution from the others on this concern while our favorite girl is in fact studying a lot. Take pleasure in the rest of the new year. You have been doing a first class job.

Leave a Reply

Your email address will not be published. Required fields are marked *