Change file timestamps
Syntax TOUCH [option]... files ... Key /t year month day hour minute second
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)
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:
COPY /B Source.txt+,,Source.txt
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.
or as a batch file:
COPY /B %1+,, %1
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
To set the date to 7:30 am 1st October 2015 TOUCH /t 2015 10 01 07 30 00 MyFile.txt
#And smiles you'll give and tears you'll cry
And all you touch and all you see
Is all your life will ever be# ~ Pink Floyd (Breathe)
Q299648 - Date and
Time Stamps for Files and Folders (FAT vs NTFS)
COPY - Copy one or more files to another location.
Equivalent PowerShell Script: touch - Change file timestamps.
Equivalent bash command (Linux): touch - Change file timestamps.