I know how to assign the current time and date to a file using copy /b filename.ext +,, but how can I assign it a different time and date, as in this variable: set DateTime=01/01/1970 03:00 AM?
Asked
Active
Viewed 1,169 times
2
1 Answers
2
This cannot be done natively in Windows CMD.
You can use NirSoft's NirCmd (free downlaod on his site http://www.nirsoft.net/utils/nircmd.html) with a command like:
nircmd.exe setfiletime "c:\temp\myfile.txt" "24-11-2015 17:57:11" "22-11-2005 10:21:56"
Another option is to do it in PowerShell as seen in the answer "How can I change the timestamp on a file?", with commands like:
$(Get-Item c:\temp\myfile.txt).creationtime=$(Get-Date "11/24/2015 5:57 PM")
Yisroel Tech
- 13,220