- certutil hash 没有其他行的冒号。
- 如果没有相应的文件,只有散列的文件没有意义
- 以下批次为两个文件夹创建哈希文件名对
- 此外,检查 folder2 中的每个散列是否存在于 folder1 - 如果不存在,则将其回显到屏幕。
@echo off
Set Dir1=A:\
Set Dir2=Q:\Test\2017\08\03\
PushD "%Dir1%"
(FOR /F "Delims=" %%A in ('DIR /B/A-D *.*'
) DO For /f "delims=" %%B in (
'certUtil -hashfile "%%A" SHA1 ^| findstr /V ":"'
) Do Echo %%B %%~fA
)> "%Dir2%\output1.tmp"
PopD
PushD "%Dir2%"
Type Nul >output2.tmp
FOR /F "Delims=" %%A in ('DIR /B/A-D *.* ^|Findstr /LIVE ".tmp"'
) DO For /f "delims=" %%B in ('certUtil -hashfile "%%A" SHA1 ^| findstr /V ":"') Do (
>> output2.tmp Echo %%B %%~fA
Findstr "%%B" output1.tmp >Nul 2>&1 || Echo Hash %%B not in "%Dir1%" File %%~fA
)
)
PopD
样品运行:
> Q:\Test\2017\08\03\SO_45494397.cmd
Hash fcfd29ab1ba8b64411d5ce461a35f07907862533 not in "A:\" File Q:\Test\2017\08\03\Get-EpubMetaInfo.ps1
Hash aa37d47dc96380532c88559045b6c3fa080e2556 not in "A:\" File Q:\Test\2017\08\03\Get-MSebooks.ps1
Hash ae29aeca5a433993ec854ddea6d8469516d2293c not in "A:\" File Q:\Test\2017\08\03\Handle-ZipFile.psm1
Hash 2d0d7fc7927f007b8aba4032d1c9fe86074ec8a1 not in "A:\" File Q:\Test\2017\08\03\SO_45494397.cmd
示例输出_.tmp
> Type output1.tmp
c10937240668c7c09dbac247b5cb0e30f027cfe6 A:\SO_45490060.cmd
47c005b12889d32107b53bdbd16e94f029d330c4 A:\SO_45491838.cmd
af6cccbeec7b80cbb37143316bd910bf6dcf622e A:\SO_45494397.cmd
> Type output2.tmp
fcfd29ab1ba8b64411d5ce461a35f07907862533 Q:\Test\2017\08\03\Get-EpubMetaInfo.ps1
aa37d47dc96380532c88559045b6c3fa080e2556 Q:\Test\2017\08\03\Get-MSebooks.ps1
ae29aeca5a433993ec854ddea6d8469516d2293c Q:\Test\2017\08\03\Handle-ZipFile.psm1
c10937240668c7c09dbac247b5cb0e30f027cfe6 Q:\Test\2017\08\03\SO_45490060.cmd
47c005b12889d32107b53bdbd16e94f029d330c4 Q:\Test\2017\08\03\SO_45491838.cmd
52b8e933411859e450fde3e8735658d9f52159b0 Q:\Test\2017\08\03\SO_45494397.cmd