Page 1 of 1

Filename, filesize, file compare

Posted: 28 Dec 2009 16:42
by Honey
I'd like to have a batch that compares 2 binary files that I enter as arguments %1 and %2 (for example, original.exe e modified.exe) and writes in a file the %1 filename and filesize, compares the two files and, for example, produces an output of this kind

Code: Select all

Filename:original.exe 
Filesize:1416277
00008549: F9 09
0000915A: 15 16
0000956A: 74 90
00127420: 37 78
00125824: 7A F8


I wrote this batch.bat

Code: Select all

@echo off
echo %~1 > out.dat
echo %~z1 >> out.dat
fc /b %1 %2 >> out.dat
pause


and I get this result

Code: Select all

original.exe 
1416277
Confronto in corso dei file original.exe e modified.exe
00008549: F9 09
0000915A: 15 16
0000956A: 74 90
00127420: 37 78
00125824: 7A F8


So far so good, but I would like to have the first 2 lines in the form
Filename:original.exe
Filesize: ...

and delete the useless 3rd line

How do I have to change the batch.bat? :wink:

Posted: 28 Dec 2009 18:14
by !k

Code: Select all

@echo off
echo Filename:%~1> out.dat
echo Filesize:%~z1>> out.dat
fc /b %1 %2| findstr /c:": ">> out.dat
pause

Posted: 28 Dec 2009 23:43
by Honey
Thanks a lot, just what I wanted :)