1.

Solve : File Compare using Dos command?

Answer»

Hi all,
Every time I have a file come in, I need to compare that file to all of the FILES in archive FOLDER using DOS command.
For Example:
I need to compare the file: C:\Input\myfile.txt to a set of files:
D:\Archive\myfile.txt.20050101,
D:\Archive\myfile.txt.20050202,
D:\Archive\Myfile.txt.20050303

I did some research and look like I need to use FOR command and FC command. But don’t know how to do it. Could you please help!!!!


DOS newbie
ATY
ok, so you have a file come in and you compare to the other files in the ~\Archive directory.

What actions do you wish to PERFORM if ...
a) there are differences in Archive files relative to the one received.
b) there are NO differences in Archive files relative to the one received (the received file is a possible duplicate file)
c) do you want to compare all files in the ~\Archive directory ??
d) TERMINATE the loop if the same file (contents) already exists ??

You need to identify what you want with the process.

Hope that helps some.This's what I wish to perform

c) compare one file to all files in the ~\Archive directory
d) terminate the loop if the same file (contents) already exists

The purpose for this scipt is to duplicate check the file, if the conten of the file is duplicate, return an error

Thanks,
ATYThe next code compare your file c:\input\myFile.txt with all the files in D:\Archive\ and show a message that you must change with your code:

Code: [Select]@echo off
set myfile=c:\input\myFile.txt

for %%A in (D:\Archive\*) do fc %myfile% %%A > NUL && call :equalTo %%A && goto :eof

echo There isn't any file equal to %myfile%
goto :eof

:equalTo
echo The file %1 and %myfile% are equals

good luck



Discussion

No Comment Found