This was originally needed to change the date stamp on the parent folder of some files so that the date modified matched that of the child files after a OneDrive sync to a new computer caused the parent folder to show the date of the sync, no it's original modified date.
Then this nice person did all the work and published it in a post here: https://superuser.com/questions/926053/change-the-modified-date-of-a-folders-in-possibly-powershell
I'm keeping it here for further development in order to help organize semi-large photos folders…
Get-ChildItem $root | Where-Object { $_.PSIsContainer } | Foreach-Object{ $oldest = Get-ChildItem $_.FullName | Where-Object { ! $_.PSIsContainer } | Sort-Object LastWriteTime | Select-Object -Last 1 if($oldest) { $_ | Set-ItemProperty -Name CreationTime -Value $oldest.LastWriteTime $_ | Set-ItemProperty -Name LastWriteTime -Value $oldest.LastWriteTime } else { # current directory is empty, directory LastWriteTime is left unchanged Write-Warning "Directory '$($_.FullName)' is empty, skiping..." } }
And the Created/Modified/Accessed Win GUI equivalents in Powershell are:
CreationTime = Created
LastWriteTime = Modified
LastAccessTime = Accessed