@setlocal
@echo.
@set TEMP1=slndirs.txt
@set TEMP2=C:\MDOS\clobnow.bat
@set TEMP3=C:\MDOS\xdelete.exe
@set TEMPRET=%CD%\tempret.bat
@set TEMPCHK=%CD%\objdirlist.txt
@set TEMP4=%CD%\delsublist.bat
@set TEMPF=%CD%\templist2.txt
@echo Fully clean solution directories...
@echo Changes into each directory in [%TEMP1%] file...
@echo Deletes all *.old, *.bak, etc using special BAT file call clobnow.bat
@if NOT EXIST %TEMP1% goto ERR1
@if NOT EXIST %TEMP2% goto ERR2
@if NOT EXIST %TEMP3% goto ERR3
:DNXDCHK
@if NOT EXIST %TEMPCHK% goto ERR5
@if NOT EXIST %TEMP4% goto ERR6
@echo Do you REALLY want to continue? Only 'y' keyin will continue ...
@ask Continue? Y or N :
@if ERRORLEVEL 2 goto NOASK
@if ERRORLEVEL 1 goto DOIT
@echo.
@echo Did not detect a 'y' keyin ... aborting, doing nothing ...
@echo.
@goto END

:DOIT
@REM echo Proceeding to do CLEANING...
@echo @cd %CD% > %TEMPRET%
@if NOT EXIST %TEMPRET% goto ERR4
@REM echo Processing %TEMP1% in %CD% > %TEMPF%
@echo Processing %TEMP1% in %CD%
@for /F "tokens=1" %%i in (%TEMP1%) do @(call :DOCLEAN %%i %%~nxi)
@echo Done all cleaning...
@goto END

:DOCLEAN
@if "%1x" == "x" goto :EOF
@if NOT EXIST %1\. goto NOWAY
@REM echo Processing %1 directory...
@cd %1
@echo Process %CD% dir...
@REM DO CLEANING HERE
@call %TEMP2%
@if "%1x" == "PLIBx" goto DOPLIB
:DNPLIB
@REM dir /ad >> %TEMPF%
@REM echo Doing subs from %TEMPCHK%...
@REM THIS FAILED @for /F "tokens=1" %%i in (%TEMPCHK%) do @(call :DOCLEAN2 %%i)
@REM Hmmm, problem was only with list contents, but now use this...
@call %TEMP4%
@REM echo Done %1 directory...
@call %TEMPRET%
@goto :EOF
:DOPLIB
@del *.h
@del *lib
@goto DNPLIB

:DOCLEAN2
@if "%1x" == "x" goto :EOF
@if NOT EXIST %1\. goto :NOCLEAN2
@echo Processing %1 sub-directory...
@if "%TEMP3%x" == "nox" goto DOCLEAN1
%TEMP3% %1 -dfrm
@goto :EOF
:DOCLEAN1
@cd %1
@REM DO CLEANING HERE
@call %TEMP2%
@cd ..
:DNCLEAN2
@goto :EOF
:NOCLEAN2
@echo No locate of [%1] sub-directory in [%CD%]...
@goto :EOF

:NOWAY
@echo.
@echo WARNING: Can NOT locate directory [%1]... Maybe does not exist... skipping
@echo.
@pause
@goto :EOF

:ERR1
@echo.
@echo Can NOT locate file %TEMP1% ... check name, location ...
@echo It is usually in the vc?sln??.zip file ... Did you forget to UNZIP this?
@echo.
@goto END

:ERR2
@echo.
@echo Can NOT locate file %TEMP2% ... check name, location ...
@echo This is a specialised batch file I use for cleaning...
@echo You can obtain a copy from my site...
@echo http://geoffair.net/misc/clobnow.bat.txt
@echo *** USE AT OWN RISK ***
@echo.
@goto END

:ERR3
@echo.
@echo Can NOT locate file %TEMP3% ... check name, location ...
@echo This is my POWERFUL delete progam I use for deleteing folders...
@echo You can obtain a copy from my site...
@echo http://geoffair.net/ms/xdelete.htm#warning
@echo *** USE AT OWN RISK ***
@echo But can continue WITHOUT IT...
@set TEMP3=no
@goto DNXDCHK

:ERR4
@echo.
@echo Can NOT create file [%TEMPRET%]! Aborting cleaning...
@echo.
@goto END

:ERR5
@echo.
@echo Can NOT locate file [%TEMPCHK%]!
@echo This contains the list of subdirectories to check... Aborting cleaning...
@echo.
@goto END

:ERR6
@echo.
@echo Can NOT locate batch file [%TEMP4%]!
@echo This batch process subdirectories in [%TEMPCHK%]... Aborting cleaning...
@echo.
@goto END

:NOASK
@echo.
@echo Appears ask.exe is NOT in path ... check name, location ...
@echo You can DOWNLOAD the source, and runtime EXE of my 'ask.exe' from -
@echo http://geoffair.net/ms/ask.htm#downloads
@echo.
@goto END

:END
@if EXIST %TEMPRET% del %TEMPRET%
@endlocal
