0

How to create a powershell script that moves files from one location to another specifying that any file that is 5 days old does not move?

Used Move-Item to move files from one location to another, but I need to move files which are more than 5 days old.

zivkovicf
  • 57
  • 1
  • 6
  • Does this answer your question? [Powershell get files older than x days and move them](https://stackoverflow.com/questions/20246497/powershell-get-files-older-than-x-days-and-move-them) – Martheen Nov 16 '22 at 07:13

1 Answers1

0

I think this pipeline should works for you

Get-ChildItem -Path C:\Downloads -File | Where-Object { $_.CreationTime -lt (Get-Date).AddDays(-5)} | Move-Item -PipelineVariable $_ -Destination C:\button
ersati
  • 85
  • 4