Skip to content

Instantly share code, notes, and snippets.

@seanwu1105
Last active March 3, 2019 08:32
Show Gist options
  • Save seanwu1105/992ea672d05f8975e0eabfc849f5b4d3 to your computer and use it in GitHub Desktop.
Save seanwu1105/992ea672d05f8975e0eabfc849f5b4d3 to your computer and use it in GitHub Desktop.
Change the last modified, creation and access time of files in Windows.

Change Timestamps in Windows

Get Started

Open PowerShell

Open PowerShell in the target directory. Normally, you can open PowerShell in current directory by holding shift and right-clicking the context menu Open PowerShell Here.

Use the Following Commands

Change Creation Time

$(Get-Item FILENAME).creationtime=$(Get-Date ["MM/DD/YYYY HH:MM am/pm"])

Change Last Access Time

$(Get-Item FILENAME).lastaccesstime=$(Get-Date ["MM/DD/YYYY HH:MM am/pm"])

Change Last Modified Time

$(Get-Item FILENAME).lastwritetime=$(Get-Date ["MM/DD/YYYY HH:MM am/pm"])

Examples

To change the creation time of the file filename.mp4 in current folder to current date time, use the following command.

$(Get-Item ".\filename.mp4").lastwritetime=$(Get-Date)

To change the last modified time of the file filename.mp4 in current folder to 11/24/2015 06:00 am, use the following command.

$(Get-Item ".\filename.mp4").lastwritetime=$(Get-Date "11/24/2015 06:00 am")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment