Kode
Kode

Reputation: 3215

PowerShell Rename-Item Doesn't Update File TimeStamp

I am using PowerShell's rename-item command to change a file extensions as follows, but it doesn't update the timestamp on the file:

Get-Item 'C:\mytest.config' | Rename-Item -NewName { $_.name -Replace '\.config','.config.disabled' }

Does rename-item not update the timestamp, and if so, how can I update the timestamp when I rename a file using the method above?

Upvotes: 0

Views: 444

Answers (1)

Rex Yu
Rex Yu

Reputation: 21

Renaming a file doesn't update its Last Modified timestamp.

However, you can update the timestamp using this in PowerShell:

(Get-Item '.\example.txt').LastWriteTime = Get-Date

Upvotes: 2

Related Questions