vevy wrote:You can simplify the certutil line by filtering out lines with ":":
Code: Select all
certutil -v -hashfile %1 MD5|find /v ":"
That is a great tip, thank you.
As for the temp file in my original batch script (posted at
viewtopic.php?p=94544#p94544), it's by design: call it an instance of
Occam's razor. Contrary to your tip above, you'd be making the code more, not less, convoluted, by replacing this:
Code: Select all
CERTUTIL -v -hashfile %1 MD5 | FIND /v ":" > tmp_hash
SET /P hash=<tmp_hash
with this:
Code: Select all
for /f %%i in ('CERTUTIL -hashfile %fp% MD5 ^|find /v ^":^"') do echo %%i *%fn%>%fn%.MD5
I like code to be easily human readable. I know all about FOR loops, but I find them highly error-prone, with rather less than intuitive syntax and overall not really newbie-friendly.
Now, if you can recommend any other way of transferring command output to a local variable, I'm all ears.