I have this batch code but it is wrong, what I need is to see on screen the name of the files in folder2 that are not in folder1 comparing them with your HASH SHA1. Temporary files are in the same directory. I appreciate your comments
@echo off
cd folder1
FOR /F "Delims=" %%A in ('DIR /B/A-D *.*') DO (
certUtil -hashfile "%%A" SHA1 | findstr /VI "HASH"| findstr /VI "certutil"
) >>folder2\output.tmp
cd folder2
FOR /F "Delims=" %%B in ('DIR /B/A-D *.* ^|Findstr /VEIL ".tmp"') DO (
certUtil -hashfile "%%B" SHA1 | findstr /VI "HASH"| findstr /VI "certutil" >>output2.tmp
FOR /F "Delims=" %%C in ('TYPE output2.tmp^|findstr /XLIV /G:output.tmp') DO (echo "%%B")
)
Sample run:
Sample output_.tmp
Here's another solution that uses no temporary files. Instead, it creates a sort of associative array like
f|filename.ext=hash
. All the hashes are stored as variables, and the series of variables can be enumerated withset "f|"
. Basically, this makes it easy to get a list of hashes tied to filenames in directory 1, then use this list to compare directory 2. If an expected variable is undefined, then the file in directory 2 does not exist in directory 1. If it is defined, then compare the hashes and undefine it. Whatever is left defined at the end indicates a file exists in directory 1 but not in directory 2.