By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!That's not true. It's mathematically impossible for any hash of limited length (or any finite combination of such hashes) to fail to have "collisions" (different files with the same hash). And the files don't have to be very big.SHA* will tell you if the files are the same. CRC32 will tell you that they're probably the same -- CRC32 is not guaranteed to be unique.
Even better, if comparing byte-by-byte (or word-by-word) you can fail immediately when a difference is seen. With any checksum algorithm you always need to read the entire files.Why use checksums at all? To compute checksums, you must open both files and read them through to the end. If you're going to do that, why not just do a byte-for-byte comparison?
And if the file sizes differ, you don't need to read even a single byte.Even better, if comparing byte-by-byte (or word-by-word) you can fail immediately when a difference is seen. With any checksum algorithm you always need to read the entire files.
Even better, if comparing byte-by-byte (or word-by-word) you can fail immediately when a difference is seen. With any checksum algorithm you always need to read the entire files.
And if the file sizes differ, you don't need to read even a single byte.
I copied v:\22extract\ to v:\22extractxx. This is crude but it seems to work. It's slow because of all the @SHA512s. It would be easier to polish it up if it were in a BTM. It only does a one-way search, i.e., for each file in c:\22extract\ it looks for one in v:\22extractxx\. I suppose you could do it in both directions.How would I compare two folder trees and make a list of files that are in the same sub-folder and has the same SHA* value and size?
do f in /d"v:\22extract" /s * ( set full=%@full[%f] & set target=%@rereplace[(?i)v:\\22extract,v:\\22extractxx,%full] & if exist %target .and. %@sha512[%target] == %@sha512[%full] echo %full = %target )
V:\22extract\8FFDD1C = v:\22extractxx\8FFDD1C
V:\22extract\tcmd.exe = v:\22extractxx\tcmd.exe
V:\22extract\8FFDD1C\32-bit = v:\22extractxx\8FFDD1C\32-bit
V:\22extract\8FFDD1C\ANSI32.dll = v:\22extractxx\8FFDD1C\ANSI32.dll
Thank you Vince.
1) What does "(?i)" mean?
2) do f in /d"v:\22extract" /a: /s *
if I wanted to do all files - even hidden / system?
In each directory, I made a directory "a&b" containing a file "c&d". The only change I made to the command was to quote the (only) occurrence of %f. That worked, producing the expected output and no errors.One last thing - I have some files / folder names with "&" - how best to do the DO from above?
do f in /d"v:\22extract" /s * ( set full=%@full["%f"] & set target=%@rereplace[(?i)v:\\22extract,v:\\22extractxx,%full] & if exist %target .and. %@sha512[%target] == %@sha512[%full] echo %full = %target )
"V:\22extract\a&b" = "v:\22extractxx\a&b"
"V:\22extract\a&b\c&d" = "v:\22extractxx\a&b\c&d"
If you put it into a BTM, which I recommend, you won't need the "&" characters and SETDOS might work nicely.Thank you again Vince. I was trying to solve it by playing with SETDOS /C
set dir1=%@rereplace[\\,\\\\,%1]
set dir2=%@rereplace[\\,\\\\,%2]
gosub process > %3
quit
:process
do f in /d"%dir1" /s *
set full=%@full["%f"]
set target=%@rereplace[(?i)%dir1,%dir2,%full]
iff exist %target then
if %@sha512[%target] == %@sha512[%full] echo %full = %target
endiff
enddo
return
Dupfind.btm v:\22extract v:\22extractxx v:\dupfiles/txt
What about the COMMENT block?
[C:\Users\Galloway\Desktop\DupFind]Dupfind.btm c:\DataBackup i:\ C:\Users\Galloway\Desktop\DupFind\samefile.txt
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\Dupfind.btm [8] The system cannot find the file specified.
""
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\Dupfind.btm [8] The system cannot find the file specified.
""
on error ( echo %full & echo %target & quit )
"V:\22extract\DataBackup\Program Files (x86)\Hewlett-Packard\HP Setup\ZH_TW_eula.html" = "v:\22extractxx\DataBackup\Program Files (x86)\Hewlett-Packard\HP Setup\ZH_TW_eula.html"
[C:\Users\Galloway\Desktop\DupFind]MaxLen.btm c:\
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [3] The system cannot find the file specified.
""
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [3] The system cannot find the file specified.
""
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [3] The system cannot find the file specified.
""
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\ProgramData\Microsoft\Diagnosis\SoftLanding\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\ProgramData\Microsoft\Diagnosis\SoftLandingStage\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\ProgramData\Microsoft\WwanSvc\Profiles\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\System Volume Information\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Users\All Users\Microsoft\Diagnosis\SoftLanding\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Users\All Users\Microsoft\Diagnosis\SoftLandingStage\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Users\All Users\Microsoft\WwanSvc\Profiles\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Windows\Registration\CRMLog\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Windows\System32\com\dmp\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Windows\System32\LogFiles\WMI\RtBackup\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Windows\System32\spool\PRINTERS\"
TCC: (Sys) C:\Users\Galloway\Desktop\DupFind\MaxLen.btm [9] The system cannot find the path specified.
"C:\Windows\SysWOW64\com\dmp\"