Search code examples
batch-filecommand-linemd5checksum

Write checksum per folder


I'm trying to write a script that will run through a directory tree and generate a checksum for the contents of each folder and write the checksum to that folder; I've managed to do everything with the following code except write the checksum to the folder, it's currently writing everything to the root directory.

FOR /R "C:\_input\test" /D %%a IN (*) DO md5deep64 -r "%%a" >> "%%a.md5"

I thought I might be able to do something with the various modifiers (%~I) but no joy. Any ideas?


Solution

  • Based on your latest comment and my own, I think this may be what you want:

    As a batch file:

    @For /D %%A In ("C:\_input\test\*) Do @md5deep64 -r "%%A">"%%A.md5" & @Move /Y "%%A.md5" "%%A"
    

    At the command line:

    For /D %A In ("C:\_input\test\*) Do @md5deep64 -r "%A">"%A.md5" & @Move /Y "%A.md5" "%A"
    

    Note that md5deep64.exe would need to be in the current directory or %Path%, otherwise you'd need to provide the full or relative path to it.