[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 4343 Date : 2003-04-18 Author : Garry Deane Subject : Re: Sync two folders problem Size(KB) : 2
--- In xxcopy@yahoogroups.com, "profasaurus" wrote: > Taking this to the next step (for a true folder sync), > what way would you suggest to copy all files between > folders (the source to dest and the dest to source), > but delete all identical filenames/size in the dest > folder, that were manually deleted (no longer exist) > in the source folder? No offence but I really think you're wasting you're time trying to set up other than a very simplistic synchronisation using Xxcopy. If you work in a linear fashion i.e. work on PC1 and synchronise changes to PC2 then work on PC2 and synchronise changes back to PC1, you've got a reasonable chance but otherwise, you're going to get into strife. Without in any way endorsing the following software, take a look at this link to get a feel for the sort of scenarios that might need to be addressed in anything beyond a rudimentary one-way synchronisation http://www.easy2sync.de/en/produkte/easy2sync_bsp.php. To try to handle these sorts of issues with Xxcopy would become very complex and necessarily would mean making a number of assumptions about how to handle certain situations. You'd be much better off spending a couple of $100 on buying some specialised software. Having said that, here's how you might go about the specific task you asked for help on. Since the only practical way to keep track of deleted files is to use a zero file length reference directory, you can't check whether the size of a deleted file is identical in the destination directory - there's nothing to compare against. But that doesn't matter because the timestamp must necessarily indicate whether the file has changed so you don't delete files in the destination unless the timestamp of the old file in the reference directory is the same. @echo off set src=d:\test\ set ref=d:\ref\ set dst=f:\test\ set log=%temp%\xxdel.log if not exist %ref% goto :initialise :: Clear the archive bit for all files in ref xxcopy %ref% /s /az > nul :: Set the archive bit in ref excluding any that exist in src xxcopy %ref% %src% /bu /bb /aa > nul :: Delete files in dst where the ref file has the archive bit :: set and the timestamps match xxcopy %ref% %dst% /bu /rdy /a /ds /pd0 /of3 /fmdtl /on%log% if not errorlevel 1 goto :initialise if errorlevel 100 if not errorlevel 101 goto :initialise echo An error occurred during deletion of files in %dest% echo The reference directory %ref% has not been updated. echo Check the error log file %log% goto :eof :initialise echo Updating reference directory. xxcopy %src% %ref% /bu /tr0 /x*.tmp > nul :eof
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.