How to Change the Date & Time of multiple files using PowerShell script

Опубликовано: 08 Октябрь 2024
на канале: Fun & Tech
652
4

Specify the path to the file
$filePath = "D:\DCIM\100GOPRO\*.*"

Specify the new date and time you want to set
$newDateTime = Get-Date "2023-07-22 15:30:00"

Set the LastWriteTime (Modified) attribute of the file
Set-ItemProperty -Path $filePath -Name LastWriteTime -Value $newDateTime

Set the LastAccessTime (Accessed) attribute of the file
Set-ItemProperty -Path $filePath -Name LastAccessTime -Value $newDateTime

Set the CreationTime (Created) attribute of the file
Set-ItemProperty -Path $filePath -Name CreationTime -Value $newDateTime