header image

Change file times

Posted by: | December 30, 2018 Comments Off on Change file times |

When a file is created, accessed or modified that time is recorded. This is how to change file times.

There are three properties to consider:

CreationTime

LastAccessTime

LastWriteTime

 

Just to add to the fun there are UTC (GMT in real world) times as well:

CreationTimeUtc

LastAccessTimeUtc

LastWriteTimeUtc

 

If you need to change a property its a set operation. For instance

Get-ChildItem -Path x9.txt | foreach {$_.LastWriteTime = ($_.LastWriteTime).AddHours(6)}

 

Substitute the appropriate property as required. If you change a property the UTC version is changed in step – accounting for timezone differences

under: PowerShell

Comments are closed.

Categories