Simple Folder Synchronization Using XCOPY

There are many times when it is necessary to make sure that one folder stays in synch with another.  The possibilities are endless, but one that I run into a lot is the need to retry copying files to a folder because they were in use when I tried the first time.  For example, I may be deploying a new build of Smart Client software but somebody is in the application so it can not be overwritten on the network. 

In order to combat this, the solution is simple.  Just using the right switches of XCOPY can work pretty smooth.  Here is a quick way to recursively copy all files.


set AttribPromptSwitch=/i/f/s/e/r/h/d/y/z

That one line in a .bat file can be magic if you want to do the same things that I typically do, which is “Make this folder look like that one and don’t ask me any questions!

@echo off
time /t

REM ————————-
REM ————————-
set COPYSOURCE=”C:\temp\SimpleSynch\ThisFolder”
set COPYTARGET=”\\Server\Share\ThatFolder”

del SynchFromThisToThat.logs

set AttribPromptSwitch=/i/f/s/e/r/h/d/y/z

REM ————————-
REM ————————-
echo “Copying from:
echo “to:

REM This is where the actual work is done
xcopy %COPYSOURCE%\*.* %COPYTARGET% %AttribPromptSwitch% >> SynchFromThisToThat.log

time /t


If you want more detail on what each of the switches do, here are a few good references:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: