After an unfortunate CHKDSK analysis which corrupted many files on a 3TB HDD (erroneously detected as 746 GB, probably because of a USB2 controler being incompatible with capacities over 2TB), I would like to make a precise comparison of those files (with their correct counterparts on a backup HDD), and extract the corrupted areas for further investigations, before deleting them.
So far, I proceeded like this :
- Open both versions of the file in WinHex. Activate the “Synchronize & Compare” display.
- Run a comparison at offset 0, save a report (mandatory with this software, no way to directly find the next difference) with the name of the file, specify a limit of 10000 errors (to avoid having too large reports).
- Once it stops (having reached the end of the file or the limit of 10000 different bytes), open the TXT report, copy the offset of the first difference into WinHex's "Go to offset" menu. Mark the first error (which is always at a sector boundary) as the begining of a block.
- Search the end of the corrupted area by scrolling down, or if it takes too long by adding 1MB or 100KB until I'm out and then scrolling up (I found no way to make this easier in WinHex). Mark the end of the last sector of the corrupted area as the end of the block.
- Extract the block as a new file, with the pattern "Name_of_the_file [1111-2222]" where "1111-2222" are the begining-end offsets.
- Resume the comparison at the end of the previously identified corrupted area, to search for others, until the end of the file...
Now, would there be a way to automate this painstaking and time-consuming process ? Are there other hexadecimal editors better suited for file comparisons ? Or could I use a script to get this done all at once ? I found a brilliant little command line tool called dsfok (DS File Ops Kit) which can extract a block of data between two offset values (among other functions which I haven't tested yet). So I would need another command line tool to perform the comparison and get those offset values, and tips to write a script to make those tools work together. Thanks.