It’s sometimes useful to be able to change a file’s modification date. Linux makes it easy by simply using the “touch” command. I found this rather useful in cases where files were transferred between servers, which unfortunately do not have their times synchronized.
So, how can this be done on Windows?
Here is the command to issue in order to modify a single file’s modification time:
But in most cases, you’d be looking at mass-changing the modification date of files inside a certain directory. To do so, use the following command:
for %f in (c:\path\to\folder\*.*) do copy %f,,+
This would loop over all files containing a “dot” (i.e. extension) in c:\path\to\folder, and changes their modification time to the current system time. If for example you want the above to only go through XML files within that folder, then use *.xml instead of *.*
PS: the above command would work if you’re manually issuing it via the command prompt. However, if you’d like to embed that it in a batch file, make sure to replace %f with %%f. In other words, the command would turn into:
for %%f in (c:\path\to\folder\*.*) do copy %%f,,+