Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using FC (File Compare) 2

Status
Not open for further replies.

pnad

Technical User
May 2, 2006
133
0
0
US
Hello,

I am using FC on a Windows Server 2003 machine as follows:

@ECHO OFF
if exist EmptyFile.xls goto :EXECUTE
goto :END

:EXECUTE
FC ErrorFile.xls EmptyFile.xls | FIND "FC: no dif" > nul
IF ERRORLEVEL 1 goto :hasdata
IF ERRORLEVEL NOT 1 goto :END

:END
exit

:hasdata
echo "hello"
goto :END

Both files are empty but the timestamp on the 2 files is different by a couple of seconds. Is there a way that I can make FC ignore the timestamp on the 2 files? I have tried ascii and binary compares but they both do not ignore the timestamp.
 
From what I see in the "fc.exe /help" command, there really is not a way to exclude the timestamp difference. However, I have used fc.exe in the past, via script, and I do not remember ever dealing with a timestamp issue, being reported as a difference. Have you tried without the "|FIND "FC:no dif">nul" command?
 
Actually, the FC was working fine (i.e. it did not seem to include the timestamp difference) but then I guess the server team applied some patches and it broke the FC program.

I just tried it without the "|FIND "FC:no dif">nul" command but that didnt work either. It still takes the timestamp difference into account.

Are there any other similar programs similar to fc that can be used?
 
The PCTools program used to be able to set the time and date stamp on a file. You might check into that so you would have to matching files for testing.

David
 
The CLI version of the gnuwin32 port of diff would probably do fine indeed, used it on various occasions.

You could also compute the file hashes and compare those. MS has a freely downloadable command line tool to compute hashes:

You could use it in a script the following way:

@echo off
set file1=[path_to_file1]
set file2=[path_to_file2]
for /f %%i in ('"fciv.exe %file1%"') do @set hash1=%%i
for /f %%i in ('"fciv.exe %file2%"') do @set hash2=%%i
if "%hash1%"=="%hash2%" goto :somewhere

:somewehere_else
echo hello world
goto :end

:somewhere
echo hello world

:end
 
Thank you all for your help.

I ended up using the FCIV program to compute hashes and then comparing those.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top