none
How to Mirror files from one directory to another RRS feed

  • Question

  • Hello Scripting guys,

     I am working on creating a script that will copy files from one place to another

    Currently I am using

    Copy-Item $filepath1 $filepath2 -Recuse

    This is working to copy the files fine, however can you assist me if mirroring the files. What I mean by this is that if $filepath1 gets new files they will be copied to $filepath2 and if Files are removed from $filepath1 they are deleted from Filepath2.

    I have been unable to locate how to do it online, is there a way to mirror the directories.

    Thank you in advance.

    Richard

    Tuesday, May 30, 2017 7:38 PM

Answers

  • I wanted to post the Answer,

    I was able to find that Robocopy was able to be used in PowerShell. by using the /MIR at the end it will do exactly what I needed.

    Robocopy $filepath1 $filepath2 /MIR

    This works.

    • Marked as answer by Richardlaw Tuesday, May 30, 2017 7:46 PM
    Tuesday, May 30, 2017 7:46 PM

All replies

  • I wanted to post the Answer,

    I was able to find that Robocopy was able to be used in PowerShell. by using the /MIR at the end it will do exactly what I needed.

    Robocopy $filepath1 $filepath2 /MIR

    This works.

    • Marked as answer by Richardlaw Tuesday, May 30, 2017 7:46 PM
    Tuesday, May 30, 2017 7:46 PM
  • 1. Use robocopy. Robocopy is a command-line tool that comes with Windows and can do directory mirroring.

    2. This is not the right place to ask robocopy questions. You can find information about robocopy by doing web searches.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, May 30, 2017 7:46 PM
    Moderator