@echo off setlocal EnableExtensions if "%~1"=="" goto usage if "%~2"=="" goto usage set "SRC=%~1" set "OUT=%~2" if not exist "%SRC%\" goto nosource if exist "%OUT%" ( echo Output file already exists: %OUT% exit /b 2 ) for %%I in ("%OUT%") do ( set "OUTABS=%%~fI" if not "%%~dpI"=="" ( if not exist "%%~dpI" mkdir "%%~dpI" ) ) where certutil >nul 2>nul if errorlevel 1 goto nocertutil echo # SHA-256 manifest generated by hash_manifest.bat> "%OUT%" for /r "%SRC%" %%F in (*) do ( if /I not "%%F"=="%OUTABS%" ( for /f "delims=" %%H in ('certutil -hashfile "%%F" SHA256 ^| findstr /r "^[0-9A-Fa-f][0-9A-Fa-f]*$"') do ( echo %%H %%F>> "%OUT%" ) ) ) echo Manifest written: %OUT% exit /b 0 :usage echo Usage: hash_manifest.bat ^ ^ exit /b 2 :nosource echo Source folder not found: %SRC% exit /b 2 :nocertutil echo certutil not found. exit /b 3