2

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?

6 Answers6

9

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

chilltemp
  • 241
0

Total Commander has a synchronization function.

0

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.

0

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".

mpbloch
  • 982
0
    cls
    @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
-1

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.

kerkeslager
  • 179
  • 1
  • 3