Thursday, July 11, 2013

Why is the syntax for touching a file from the command prompt so strange?

The magic incantation for updating the last-modified date on a file is

COPY /B FILE+,,
What strange syntax! What's with the plus sign and the commas, anyway?

The formal syntax is the much more straightforward

COPY /B A+B+C+D
This means to start with the file A, then append the files B, C, and D, treating them all as binary files.

If you omit the B+C+D part, then you get

COPY /B A+
This means "Start with A, then append nothing." The side effect is that the last-write time gets updated, because the command processor opens A for append, writes nothing, then closes the handle.

QR: Inline image 1