Filename, filesize, file compare

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Honey
Posts: 2
Joined: 28 Dec 2009 16:30

Filename, filesize, file compare

#1 Post by Honey » 28 Dec 2009 16:42

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:

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

#2 Post by !k » 28 Dec 2009 18:14

Code: Select all

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

Honey
Posts: 2
Joined: 28 Dec 2009 16:30

#3 Post by Honey » 28 Dec 2009 23:43

Thanks a lot, just what I wanted :)

Post Reply