@echo off
mode con: cols=80 lines=54
if not exist [IMG_CHK_IN] mkdir [IMG_CHK_IN]
cls
echo ##############################################
echo # Ensoniq IMG (ASR/EPS) Image Verifier v0.70 #
echo ##############################################
echo.
echo Input files must be Ensoniq raw images placed within the [IMG_CHK_IN] folder.
echo All images must have an *.img file extension, as generated by various Ensoniq
echo utilities such as EpsLin, EPSDisk, EnsoniqFS, and Translator.
echo.
echo Sub-directories are supported.
echo.
echo No changes will be made to any of the files. This utility is read only.
echo.
pause
echo.

rem -- check for required tools
if not exist .\tools\cygwin1.dll (
	echo Critical Error: cygwin cannot be found. Aborting!
	goto ENDITALL
)
if not exist .\tools\cyggcc_s-1.dll (
	echo Critical Error: cygwin cannot be found. Aborting!
	goto ENDITALL
)
if not exist .\tools\epslin.exe (
	echo Critical Error: epslin cannot be found. Aborting!
	goto ENDITALL
)

rem check for any present IMG files -- silences normal command output and also any errors produced by next "dir" command
dir /S /B /A-D .\[IMG_CHK_IN]\*.img >NUL 2>&1
if %ERRORLEVEL% equ 0 (
	rem scan entire image folder for all IMG files present
	rem needs delims== so for loop does not cut off at first space generated by DIR
	for /F "delims==" %%a in ('dir /S /B /A-D .\[IMG_CHK_IN]\*.img') do (
		cls
		echo Checking %%~Na...
		echo.
		.\tools\epslin -D "%%a"
		.\tools\epslin -C0 "%%a"
		pause
	)
) else (
    echo Aborting: No IMGs found.
	echo.
	pause
)
