Name: phoenixtb Date: February 4, 2008 at 02:55:55 Pacific Subject: Batch file that xcopy and compare OS: XP CPU/Ram: 1 gig
Comment:
Hello all,
I have a tower with 12 usb drives to duplicate usb sticks. I try to write a batch file that will allow me to copy files from a folder to the usb sticks. To write the batch file with the xcopy command to make him only copy is simple, but i want to make a compare copy that every time that he copy the files form the folder, he will make copy and compare of the files and give me a log if everything is ok or it there is a problem with one of the drives and whice one(if it possible). Any one can help me with that one please? Or maybe give me some explantion how to do it(maybe a website that explain me a little bit more how to do it).
for /f "tokens=* delims= " %%a in ('dir/b/a-d') do ( if exist C:\temp\-\matrix\x\%%a ( fc %%a C:\temp\-\matrix\x\%%a >> compare.log ) else ( echo %%a is missing >> missing.log ) )
===================================== If at first you don't succeed, you're about average.
I seem to remember in the "good old days" of MS-DOS 6, there was a native command (or possibly a supplied .exe), I think it was called UPDATE or something like that, and it did what M2's batch file above is doing. There were command-line options to copy files if the destination didn't exist, or if it was older than the source. How come there isn't such a command on XP?
/U Copies only files that already exist in destination.
I can't find an option for copying only if source is newer than destination, or only if destination file does not exist. (Which is like what your for loop in the previous reply is doing, and what the UPDATE command could do without requiring a for loop.)
Oh, I've just looked at an MS-DOS 6 Command Reference and found the command I was thinking of. It wasn't called UPDATE, it was called REPLACE. Now that I know the correct name, I can see that REPLACE also exists in Windows XP. All that moaning for nothing...
Now I can go back to my old batch files, and replace silly for loops like
for %%f in (source\*) do if not exist dest\* copy %%f dest
/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
===================================== If at first you don't succeed, you're about average.
There is any way to make the compare script to read all the files and folders without loop? or i need to build a very long script to make compare to a lot of files and folders?
or is there any way that when i write the fc command to tell him to check every folder and files?
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE