Short story: saved pictures from phone to computer, preserved last modified date, destroyed created date. So in wanting to restore them to the phone, and preserve the order in which they were made in the phone, I searched for a means to make the created date the modified date:
(get-item "picture.jpg").CreationTime = (get-item "picture.jpg").LastWriteTime
Not wanting to write a line for each of the several thousand pictures in a few dozen folders, expanded it to this first to test on a single folder:
Get-ChildItem | ForEach-Object { ($_.CreationTime) = ($_.LastWriteTime) }
And ran this with PS in test folder.
So to avoid having to run this command in each folder, I would be doing this:
Get-ChildItem -recurse | ForEach-Object { ($_.CreationTime) = ($_.LastWriteTime) }
And running that in the root folder of the saved pictures. It worked as expected.
But before I royally mess up, is my syntax correct or will I do something really catastrophic to my system or is there a better way of doing this?
P.S. While I am a computer programmer, at times I'm not good with finding the right information I need to complete a task because I'm not searching for the correct terms.
Based on the comments so far:
Get-ChildItem "[**redacted**]Phone\Pictures\" -File -Recurse | ForEach-Object { $_.CreationTime = $_.LastWriteTime }
-Fileyour code will also affect directories. Maybe you don't want that?Get-ChildItem the\path\toThePictures -Recurse ...(...)around the operands of your assignment statements.