Copy files and their paths based on file date

Welcome Forums General PowerShell Q&A Copy files and their paths based on file date

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • Author
    Posts
  • #169720

    Participant
    Topics: 1
    Replies: 1
    Points: -1
    Rank: Member

    I have a folder with 50 folders in it.  Each folder has a ton of files dating to a year ago.  I need to find all files in each of the 50 folders that are older then 6 months and then move them to a new location.  The caveat is I need them moved into the same folder structure.  The 50 folders can change each time this script is ran so it will have to copy the folder structure over and then move the files older then 6 months to the new location, with the same folder names.  Sorry, having a hard time explaining this so I hope this is good.

    I was hoping to be able to use a powershell script to do this.

    $TIME – (Get-Date).AddDays(-180)
    Get-ChildItem -Recurse |
    Where-Object {$_.LastWriteTime -lt $time}

    This is what I have so far.

    Thanks in advance,

    George Jackson

  • #169813

    Participant
    Topics: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    Can we assume that your question is answered?

    Moving Files while copying the folder structure ....

  • #169828

    Participant
    Topics: 1
    Replies: 1
    Points: -1
    Rank: Member

    I believe we can assume my question is answered.  Thank you very much!

    • #169843

      Participant
      Topics: 8
      Replies: 18
      Points: 108
      Rank: Participant

      Hah, that's funny, I was going to suggest using Robocopy when you posted, but didn't since it isn't PowerShell 😉

You must be logged in to reply to this topic.