[英]How do I make CertUtil recursively go into my folders and subfolders
Simply put I am trying to take a hash of all of my files in a given directory.简单地说,我试图对给定目录中的所有文件进行哈希处理。 I am doing this by calling CertUtil and running:
我通过调用 CertUtil 并运行来做到这一点:
for %F in (L:\TestDirectory\*)
do (certutil -hashfile "%F" MD5&echo.) >> L:\certutilOutput.txt
This works well, but only for the current directory as it does not go into my next subfolder: "L:\\TestDirectory\\NetFolder\\ which contains another set of files. I would like this to be able to go down several layers.这很有效,但仅适用于当前目录,因为它不会进入我的下一个子文件夹:“L:\\TestDirectory\\NetFolder\\,其中包含另一组文件。我希望它能够向下几层。
I feel like I am missing something very simple, any help is appreciated.我觉得我错过了一些非常简单的东西,任何帮助表示赞赏。
To base this on the original code and put it in the full solution that @dave_thompson_085 referenced, save the following as a bat file:要将其基于原始代码并将其放入@dave_thompson_085 引用的完整解决方案中,请将以下内容另存为 bat 文件:
@echo off
for /R "L:\TestDirectory" %%f in (*) do (
certutil -hashfile "%%f" MD5
)>>L:\certutilOutput.txt
Brilliant minds work alike.聪明的头脑都是一样的。 What are the odds that, after 3+ years of sitting unanswered, two of us would be working on answers to this question at the same time?
经过 3 年多的无人回答,我们中的两个人同时致力于回答这个问题的可能性有多大?
My variation features (1) the optional use of FIND to eliminate potentially unwanted clutter from the output and (2) a check to remove a preexisting output file:我的变体具有 (1) 可选使用 FIND 从输出中消除潜在的不需要的混乱和 (2) 检查以删除预先存在的输出文件:
@echo off
if exist "L:\certutilOutput.txt" del "L:\certutilOutput.txt"
for /r "L:\TestDirectory" %%F in (*) do certutil -hashfile "%%F" MD5 | find /i /v "certutil:" >> "L:\certutilOutput.txt"
Sadly, it still doesn't put both the filename and the hash on one line, which is what I've been seeking .可悲的是,它仍然没有将文件名和哈希放在一行上,这正是我一直在寻找的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.