Possible Duplicate:
How to modify timestamp in a dll or exe?
Windows equivalent of the Linux command 'touch'?
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 communityPossible Duplicate:
How to modify timestamp in a dll or exe?
Windows equivalent of the Linux command 'touch'?
How can I set the timestamp for a file via the command-line to a specific date?
My specific situation is Windows 7.
Due to William Jackson's answer, I found a similar question on Stack Overflow.
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")
Edit
Two examples:
(This one is from the comments:) Set the last-access time for a file aaa.csv
to the current time:
$(Get-Item aaa.csv).lastwritetime=$(Get-Date)
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")
powershell $(Get-Item aaa.csv).lastwritetime=$(Get-Date)
Get-ChildItem -File | foreach { $_.CreationTime=$(Get-Date) }
Dec 27, 2020 at 18:24
See the answers to this question.
Specifically, this can be done natively with:
copy /b filename.ext +,,
This will set the timestamp to the current time.
Documentation for the copy
command is on TechNet.
The commas indicate the omission of the Destination parameter.
+,,
? How do I know what date it is being set to?
Jun 3, 2011 at 20:05
pushd FILEDIR
, before the comand and popd
after
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"
Using Cygwin, to set the timestamp of test.txt to January 31, 2000, at 00:01.00:
touch -t 200001310001.00 test.txt
touch -t 201608221400 filename
to set it to 22.08.2016 14:00:00.
Nov 24, 2016 at 9:55
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.
touch
that sets a files's timestamp to the current time.touch
, I could specify the date. en.wikipedia.org/wiki/Touch_(Unix). Something is wrong with the auto linking though, make sure you get both parentheses.man touch
. You have taught me something new.