Thursday, 25 October 2018

windows - How can I change the timestamp on a file?




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.



Answer



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

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...