How can I set the timestamp for a file via the command-line to a specific date?
My specific situation is Windows 7.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
The accepted answer states to use Powershell and these commands:
$(Get-Item ).creationtime=$(Get-Date "mm/dd/yyyy hh:mm am/pm") $(Get-Item ).lastaccesstime=$(Get-Date "mm/dd/yyyy hh:mm am/pm") $(Get-Item ).lastwritetime=$(Get-Date "mm/dd/yyyy hh:mm am/pm")
(This one is from the comments:) Set the last-access time for a file
aaa.csv to the current time:
Set the creation time of a file
foo.txt to November 24, 2015, at 6:00am:
$(Get-Item foo.txt).creationtime=$(Get-Date "11/24/2015 06:00 am")
Nirsoft to the rescue: try the freeware tool nircmd. It's a bunch of useful tools in one small command line program. One of the commands allows you to specify either or both of created time and modified time, like this:
nircmd.exe setfiletime "c:\temp\myfile.txt" "24-06-2003 17:57:11" "22-11-2005 10:21:56"
Check out the following webpage: http://www.stevemiller.net/apps/
The Win32 Console Toolbox contains a utility called 'touch' that lets you modify the times on one or more files. I believe it only works with US format times, though.