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

Viewing 2 reply threads
  • 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: 2
      Replies: 1757
      Points: 3,642
      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: 9
        Replies: 26
        Points: 160
        Helping Hand
        Rank: Participant

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

Viewing 2 reply threads
  • The topic ‘Copy files and their paths based on file date’ is closed to new replies.