Tuesday, November 10, 2009

Synchronize files on two computers

Synchronize files on two computers


The Windows command line utility XCOPY has options that can be used to copy only files that are newer than those already in the destination folder. You can create a batch file to simplify this procedure.

Using Notepad, create a file containing the following two lines:

XCOPY "%1" "%2" /D /I %3
XCOPY "%2" "%1" /D /I %3

and save it in your Windows folder as SYNC.CMD. (This is for Windows 2000 or XP. If you are using Windows 95, 98 or Me, replace XCOPY with XCOPY32 and save the file as SYNC.BAT.)

To use the batch file, open a command prompt and type SYNC followed by the paths of the two folders you want to synchronize, each in quotes. If you want to synchronize subfolders as well, add /S to the command line before pressing Enter. For example, suppose your project is kept in a folder called "My Project" on both your local PC and one with a network name of "DELL". To synchronize this folder, including any subfolders, type the command:

SYNC "C:\My Project" "\\DELL\My Project" /S

We recommend that you test this on something unimportant before trying it on valuable work files. Note that the two-line batch file has no "idiot-proofing", so it will happily try to synchronize entire hard disks if you tell it to! This method works, but it gets tiresome having to type in the paths of the two folders.

This might be useful as well: XCOPY "C:/tmp" "D:/tmp" /M /C /E /I /Y

No comments: