@echo off
setlocal enabledelayedexpansion
cls
set filePath=%1
if "%filePath%"=="" (
set /p=file path is empty<nul
goto EXIT
)
if not exist %filePath% (
set /p=file is not exist<nul
goto EXIT
)
if exist %filePath%\* (
set /p=file is directory<nul
goto EXIT
)
set lineFlag=0
for /f "delims=" %%i in ('certutil -hashfile %filePath% MD5') do (
set /a lineFlag+=1
if !lineFlag!==2 (
set lineContent=%%i
goto out
)
)
:out
echo %filePath%
echo MD5:%lineContent%
:EXIT