Change File Modified Date to be the Same as the Creation Date

Rupert Eghardt
Rupert Eghardt used Ask the Experts™
on
Hi Guys,

I am trying to copy files from a folder - based on creation date to another destination.

I tried RoboCopy, but it uses the modified date, which in some instances doesn't work.

Is there perhaps a PowerShell command to change the modified date to be the same as the creation date for multiple selected files?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
All you have to do is run the output of a Get-ChildItem through a ForEach loop and assign the CreationTime (foo.txt can be anything that returns whatever you want to change):
Get-ChildItem foo.txt | ForEach-Object {$_.LastWriteTime = $_.CreationTime}

Open in new window

But what exactly is the problem with the LastWriteTime?
Rupert EghardtProgrammer

Author

Commented:
The problem is that we need files copied from a backup create/modified after the 1st of June.
Some files were modified back in 2008, but was copied to the server after the 1st of June this year.
The modified date of these copied files shows 2008, but the create date shows July 2019.

Thus copying files based on the modified date omits these files, which should actually be included in the copy process.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial