Reputation: 335
I am trying to change the lastwritedate of all files in a folder and all files in the subfolders using MS Powershell I got this far to retrieve a list of all files of concern
Get-ChildItem -Path . -Recurse -Filter *.* -File
Now I would like to change the date of the found files
(Get-ChildItem -Path . -Recurse -Filter *.* -File) | (Get-Item).lastwritetime=$(Get-Date "10/10/2019 01:05 pm")
But unfortunately it fails. Can anyone help me.
Upvotes: 0
Views: 963
Reputation: 335
ok now I found the solution
(Get-ChildItem -Path . -Recurse -Filter *.* -File) | foreach {$_.lastwritetime=$(Get-Date "10/10/2019 01:05 pm")}
this pipes the output of gci
Upvotes: 3