Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch file that xcopy and compare

Original Message
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).

Thank you very much


Phoenixtb


Report Offensive Message For Removal


Response Number 1
Name: User123456789
Date: February 4, 2008 at 04:00:11 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
You should use "FC" to compare the content of two files, and act according to what ERRORLEVEL is throwing as a result of each compare.

You may need to break down the XCOPY command, and use a FOR loop, for every file you copy (and subsequently FileCompare against each other).

If you are XCOPYing subdirectories (as compared to files IN a folder), this will become more difficult.

Actually, XCOPY should have a feature to test the copied file.

Hmm ... have a check on ROBOCOPY, the expansion to XCOPY. Or, check out XXCOPY (the non MS-expansion to XCOPY).

Hi there.


Report Offensive Follow Up For Removal

Response Number 2
Name: phoenixtb
Date: February 4, 2008 at 04:45:52 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
I will check the robocopy and xxcopy.

Thank you very much for the information :)

Phoenixtb


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: February 4, 2008 at 04:53:57 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
No need for 3rd party utility.

Use XCOPY with /v to verify files written.

To make a log:

xcopy /v *.* u:\ > log



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: February 4, 2008 at 05:07:43 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
:: compare files in 2 dirs and report any missing

@echo off
setLocal EnableDelayedExpansion

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.

M2



Report Offensive Follow Up For Removal

Response Number 5
Name: phoenixtb
Date: February 4, 2008 at 06:21:10 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
Wow,
Thanks a lot for all the information.
I never tought that i get the information that quick :).

Thank you everyone for the really really quick help :)

Phoenixtb


Report Offensive Follow Up For Removal


Response Number 6
Name: klint
Date: February 4, 2008 at 07:16:20 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
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?

Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: February 4, 2008 at 21:38:42 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
"How come there isn't such a command on XP?"

There is:

xcopy /?


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 8
Name: klint
Date: February 5, 2008 at 02:13:07 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
All I could find with xcopy /? was:

/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.)


Report Offensive Follow Up For Removal

Response Number 9
Name: klint
Date: February 5, 2008 at 02:18:56 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
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

with

replace /a source\* dest


Report Offensive Follow Up For Removal

Response Number 10
Name: Mechanix2Go
Date: February 5, 2008 at 03:11:55 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
xcopy /d

/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.

M2



Report Offensive Follow Up For Removal

Response Number 11
Name: klint
Date: February 5, 2008 at 05:45:30 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
Didn't see that at first. Thanks.


Report Offensive Follow Up For Removal

Response Number 12
Name: phoenixtb
Date: February 10, 2008 at 06:46:37 Pacific
Subject: Batch file that xcopy and compare
Reply: (edit)
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?

Phoenixtb


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch file that xcopy and compare

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs

Best WinMo phone of 2008


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

All content ©1996-2007 Computing.Net, LLC