I'm trying to find a fast way to recursively update a folder and all subfolders from another folder. Obviously, a full delete and Xcopy would work but that is very slow.

After the update, the destination folder should exactly match the source folder. Changed files and new files should be copied.

If it makes it easier, don't worry about deleting files that are in the destination folder but missing in the source folder.

This deploy/mirror/update operation seems pretty basic. Do I really need to write a C# script to accomplish it?

  • I've used Karen's Replicator in the past and it's been very good: karenware.com/powertools/ptreplicator.asp
    – nickf
    Jun 23, 2010 at 21:56
  • 1
    This belongs on superuser.com Jun 23, 2010 at 22:02
  • Unless you are using C# libraries which manipulate the NTFS file system directly, you are not going to see any performance gain over calling a process for a program which manipulates files, such as those mentioned thusfar.
    – mpbloch
    Jun 23, 2010 at 22:11
  • This is quite simple to do from .net. You compare src and destination by checking date stamps and file length. Copy what has changed only, remove what no longer exists. Oct 15, 2016 at 19:11

6 Answers 6


RoboCopy is a command line tool provided by Microsoft that can do mirroring. The Wiki page also mentions a GUI.

  • Oooh.. how did I not know about this?
    – mpbloch
    Jun 23, 2010 at 22:09
  • 3
    I use robocopy /mir source dest quite a lot Jun 23, 2010 at 22:12
  • 1
    Robocopy does work quite well, except for changes to permissions. If the only change is to permissions, that would not be picked up as a change and re-copied. To ensure that permissions are mirrored, there would need to be a second permissions-only copy with the COPY:SOU switch.
    – Greg Askew
    Jun 24, 2010 at 11:20
  • Robocopy tip: add /DCOPY:T if you want to folder timestamp to stay the same. Otherwise it will be the current timestamp.
    – Peet Brits
    Sep 29, 2014 at 12:39

Total Commander has a synchronization function.


If you're happy with doing it from the CLI, xcopy (built into WinXP) and robocopy (built into Vista/Win7) both do "only if newer" copies.


Given a folder "source" and "dest", where you want "dest" to match "source".

  1. xcopy /e /d source dest

Saw your comment "dont worry about deleting outdated files".

  • wait.. this is silly, editing..
    – mpbloch
    Jun 23, 2010 at 22:05
  • i'm pretty much doing that now but it's really slow.
    – milkplus
    Jun 23, 2010 at 22:10
    @echo off
    pushd %~dp0 >nul 2>&1
    if not "%1" == "max" start /max cmd /c %0 max & exit/b >nul 2>&1
    color 1f
    TITLE robocopy "Source" "Dest" /FFT /NC /NDL /MIR /IT /MT:1 /R:0 /W:0
    robocopy "Source" "Dest" /FFT /NC /NDL /MIR /IT /MT:1 /R:0 /W:0
    exit /b n
  • /MT:1 option only available in Win7 and up. Mar 29, 2018 at 19:40
  • 1
    please add some context to your answer, posting code alone is not enough. Some small comments will suffice. Also your comment about Win7 belongs to the answer itself, not the comment area. Mar 29, 2018 at 23:12

I would probably do this with some version control system, probably git. Just create a repo in the source and destination directories. To sync, just commit from the source directory and checkout from the destination directory.

Git is very, very fast. I've heard that Mercurial is also (though I don't know from experience).

This approach will also give you lots of flexibility if you need to do more later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.