@setlocal
@if "%1x" == "x" goto HELP
@set TEMPIN=%1
@set TEMPALL=tempall.txt
@set TEMPLOG=C:\GTools\perl\temp.amscan02.pl.txt
@if NOT EXIST %TEMPIN% goto ERR1
@REM default to scanning SUBDIRS
@set TEMPO=-s
@set TEMPNP=
:RPT
@shift
@if "%1x" == "x" goto DNDEBUG
@if /i "%1x" == "dx" goto DODEBUG
@if /i "%1x" == "d13x" goto DODBG13
@if /i "%1x" == "d15x" goto DODBG15
@if /i "%1x" == "NOPAUSEx" goto DONOPAUSE
@echo.
@echo ERROR: ONly other commands are 'D', to set '-d all' in the command...
@echo or 'd13' to set '-d 13'...
@echo or 'd15' to set '-d 15'...
@echo or 'NOPAUSE' to not pause after each file...
@echo Switch [%1] NOT KNOWN!
@echo.
@goto END
:DODBG13
@set TEMPO=%TEMPO% -d 13
@echo Setting debug 13
@goto RPT
:DODBG15
@set TEMPO=%TEMPO% -d 15
@echo Setting debug 15
@goto RPT
:DODEBUG
@set TEMPO=%TEMPO% -d all
@echo Setting debug all
@goto RPT
:DONOPAUSE
@set TEMPNP=yes
@echo Set NOPAUSE after first, or if error exit...
@goto RPT
:DNDEBUG
@set TEMPC=0
@set TEMPC2=0
@echo Moment, getting count of files to process...
@for /F "tokens=1,*" %%i in (%TEMPIN%) do @(call :CNTIT %%i %%j)
@echo Got %TEMPC% am files to scan...
@if "%TEMPC2%x" == "0x" goto DNMISS
@echo WARNING: There appear %TEMPC2% files MISSING...
:DNMISS
@echo *** CONTINUE? ***
@pause

@echo Being of %TEMPC% scans ... >%TEMPALL%
@set TEMPC2=0

@for /F "tokens=1,*" %%i in (%TEMPIN%) do @(call :DOIT %%i %%j)

call np %TEMPALL%

@goto END

:CNTIT
@if "%1x" == "x" goto :EOF
@if "%2x" == "x" goto :EOF
@if "%1x" == "1x" goto CNTIT2
@goto :EOF
:CNTIT2
@if NOT EXIST %2 goto NOCNT
@set /A TEMPC+=1
@goto :EOF
:NOCNT
@set /A TEMPC2+=1
@goto :EOF

:DOIT
@if "%1x" == "x" goto :EOF
@if "%2x" == "x" goto :EOF
@if "%1x" == "1x" goto DOIT2
@goto :EOF
:DOIT2
@set TEMPF=%2
@if NOT EXIST %TEMPF% goto NOFILE
@if EXIST %TEMPLOG% del %TEMPLOG%
@set /A TEMPC2+=1
@set TEMPS=%~z2
@echo %TEMPC2% of %TEMPC%: Scan of %TEMPF%, %TEMPS% bytes, 
@call amscan %TEMPF% %TEMPO%
@if ERRORLEVEL 1 goto GOTERR
:ENDFIL
@echo ================================= >>%TEMPALL%
@echo %TEMPC2% of %TEMPC%: Scan of %TEMPF%, %TEMPS% bytes >>%TEMPALL%
@if NOT EXIST %TEMPLOG% goto NOOUTF
@type %TEMPLOG% >>%TEMPALL%
@del %TEMPLOG%
@if "%TEMPNP%x" == "yesx" goto :EOF
@echo Check results...
@pause
@goto :EOF

:NOOUTF
@echo.
@echo ERROR: Script did NOT create a [%TEMPLOG%] file!
@echo There appears some BIG PROBLEM...
@echo.
@pause
@echo Suggest Ctrl+C to ABORT!!!
@pause
@goto END


:GOTERR
@echo %TEMPC2% of %TEMPC%: Doing file %TEMPF%, got ERRORLEVEL=%ERRORLEVEL%
@echo %TEMPC2% of %TEMPC%: Doing file %TEMPF%, got ERRORLEVEL=%ERRORLEVEL% >>%TEMPALL%
@pause
@goto ENDFILE

:NOFILE
@echo ERROR: File [%2] does NOT exist!
@pause
@goto :EOF

:HELP
@echo.
@echo HELP
@echo Give an input file, containing a LIST of configure.ac files to scan...
@echo.
@goto END


:ERR1
@echo ERROR: Can NOT locate file [%TEMPIN%]! Check name, and location...
@goto END

:END
