2

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?

1 Answer 1

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")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .