Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync two folders using batch file

Tags:

I want to use a batch file to synchronize 2 folders on Windows, and I'm using the xcopy command like this

xcopy /s /d <Original Folder> <Destination Folder> 

It's working perfectly because I just want to overwrite only the modified ones, but I have 1 tiny problem, when I delete a file from the original folder, that file remains in the destination folder when i run the batch file, breaking the synching I want to achieve... I think this can't be done with xcopy, but I don't know which command I should use in case I delete a file in the original folder.

EDIT: This programs is for people who don't understant a lot of PC's so i don't want to install anything in their pc's. Just want a plain batch file to keep the 2 folders synchronized

SOLUTION: Thanks to Kuba Wyrostek I got to this command

robocopy <Original Folder> <Destination Folder> /e /purge

Thank you all for your time

like image 450
HoTag Avatar asked Oct 07 '14 19:10

HoTag


1 Answers

xcopy has no such option. Your alternatives are:

rsync - http://rsync.samba.org

robocopy - http://technet.microsoft.com/en-us/library/cc733145.aspx

like image 167
Kuba Wyrostek Avatar answered Oct 06 '22 07:10

Kuba Wyrostek