简体   繁体   English

如何让 CertUtil 递归进入我的文件夹和子文件夹

[英]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.

相关问题 如何从python中的两个列表创建具有多个子文件夹的多个文件夹 - How do i make multiple folders with multiple subfolders from two lists in python 如何在PowerShell中比较两个文件夹和创建缺少的子文件夹 - How do I Compare Two Folders and Create Missing Subfolders in PowerShell 如何使我的 BATCH 文件影响子文件夹? - How can I make my BATCH file affect subfolders? 在Win32中删除子文件夹本身之前,如何从文件夹和子文件夹中删除文件? - How can I delete files from folders and subfolders before deleting the subfolders themselves in Win32? 如何批量合并两个文件夹,包括子文件夹 - How to merge two folders including subfolders in batch 如何使用批处理脚本使用另一个目录的子文件夹名称在目录中创建新的空文件夹? - How can I create new empty folders in a directory using names of subfolders of another directory using batch script? 我怎样才能让这个 perl 命令也检查子文件夹? - How can I make this perl command check for subfolders as well? 如何在匹配字符串并忽略大小写的 Windows 中递归重命名文件夹 - how can i recursively rename folders in windows matching string and ignoring case 新秀问:如何将空文件夹推送到BitBucket git存储库中 - Rookie Q: How do I push empty folders to my BitBucket git repo 批量创建文件夹和子文件夹 - Creating folders and subfolders in batch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM