![]()
[<<]Message[>>] [<<]Author[>>] Subject Thread
Number : 3254 Date : 2002-12-12 Author : Kan Yabumoto Subject : Sync operation using XXCOPY Size(KB) : 3
One notable example of making two-line batch file which is superior to a one-step solution is the sync operation. From time to time, people ask "Does XXCOPY support a Sync operation?". Usually he is talking about connecting a notebook computer and a desktop computer and making two directories from each machine to sync one another --- copying newer files and brand new files from Machine A to B and do the same thing from Machine B to A. Currently, such bi-directional operation in one breath is not supported by XXCOPY. I do get an urge to make XXCOPY do that, just so that we can say "Yes, of course, XXCOPY can do everything". But, after some thought, I always come to the sense that it should not be supported in XXCOPY. Why? Because XXCOPY has a one directional operation model Source ---> Destination. And, /X switch (and others) rely on the "source base directory" which is always a single directory somewhere in the source. And, XXCOPY has myriad of operations that works harmoniously with this model. Now, adding the new concept of switching the source directory and destination would have so much impact (mostly adverse one) on so many existing switches. With a "bidirectional sync" command, we will have to disable" many switches while /SYNC operation is in effect. Technically, adding the sync operation to XXCOPY is very easy. Just the mess caused by adding the /SYNC switch is devastating. Then, let us look at the alternative to the one-line-sync command. All you need to do is to write a two-line batch. xxsync1.bat ------------------------------------------------------------------ xxcopy "c:\My Documents\" "\\notebook\c\My Documents" /bn/e/h/r/y xxcopy "\\notebook\c\My Documents" "c:\My Documents" /bn/e/h/r/y ------------------------------------------------------------------ This rudimentary sync script can made as fancy as you want. xxsync2.bat -------------------------------------------------------------------------- xxcopy "c:\My Documents\" "\\notebook\c\My Documents" /cfc:\bin\sync.xcf xxcopy "\\notebook\c\My Documents" "c:\My Documents" /cfc:\bin\sync.xcf -------------------------------------------------------------------------- Here, let me show you a somewhat realistic example of the "command file" switch (/CF). c:\bin\sync.xcf (xxcopy command file) --------------------------------------------------------------------- // this script is for sync job. // src and dst need to be specified on the main command line // will synchronize my notebook and home desktop computers. /bn // copy brandnew and newer files /e // subdirs including empty ones /h // include hidden/syste files /r // overwrite read-only files /y // suppress prompt on overwrite /ks // keep the src file attrib including R-bit /oac:\bin\mylog.txt // append log file /x*.tmp // exclude junk /x*.mp3 // exclude my kids stuff --------------------------------------------------------------------- If you see how elaborately you can customize the sync operation to fit to your requirement using two-step solution, one should not ask for one-liner sync command which will most likely be inferior to this scheme. Kan Yabumoto
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.