Bat计算MD5值
@echo offset Name1=*.ADS
for %%F in (%Name1%) do (
::获取md5值
echo %%F
certutil -hashfile %%F MD5 >APP_MD5_TXT
setlocal enabledelayedexpansion
set index=0
for /f "tokens=* delims= " %%i in (APP_MD5_TXT) do (
echo %%i
if !index! == 1 (set md5=%%i)
set /a index=index+1
)
del APP_MD5_TXT
REM 移除md5中的空格,兼容md5出现空格的情况
set md5=%md5: =%
echo 当前文件MD5: %md5% >>abc.txt
)
pause
请问大佬们,为什么这个最终输出的MD5的值是空的
@echo off
set Name1=*.ADS
echo MD5的空格需要手动去掉>abc.txt
for %%F in (%Name1%) do (
::获取md5值
certutil -hashfile %%F MD5 >APP_MD5_TXT
setlocal enabledelayedexpansion
set index=0
for /f "tokens=* delims= " %%i in (APP_MD5_TXT) do (
::if !index! == 1 (set md5=%%i)
if !index! == 1 (echo 当前文件MD5: %%i文件名: %%F>>abc.txt)
set /a index=index+1
)
del APP_MD5_TXT
REM 移除md5中的空格,兼容md5出现空格的情况
set md5=%md5: =%
echo 检测到文件: %%F
)
pause Monitor 发表于 2019-7-25 12:21
@echo off
set Name1=*.ADS
echo MD5的空格需要手动去掉>abc.txt
多谢大佬回答,后面试过了,把md5=%md5: =%换成set md5=!md5: =!就可以去掉空格了
页:
[1]