@setlocal
@echo Revert temp\*.dsp files back to last BACKUP
@set TEMPD=temp
@if NOT EXIST %TEMPD%\. goto NODIR

@cd %TEMPD%

@set TEMPC=0
@for %%i in (*.dsp *.dsw) do @(call :CHKIT %%i)
@echo Found %TEMPC% to revert... copy *.bak to *.dsp
@echo *** CONTINUE? ***
@pause
@echo Doing %TEMPC% DSP files...
@echo *** ARE YOU SURE? ***
@echo This action COPIES the *.bak ONTO the *.DSP, and there is no REVERSAL
@echo *** CONTINUE? ***
@pause
@echo *** REAL, REAL SURE? *** LAST CHANCE...
@echo *** CONTINUE? ***
@pause
@set TEMPD=0

@echo Doing it... moment...
@for %%i in (*.dsp *.dsw) do @(call :REVIT %%i)
@REM call REVIT temp.glib.dsw
@echo Done %TEMPD% copies...

@cd ..

@goto END

:CHKIT
@set TEMPF1=%1
@set TEMPF2=%1.bak
@if "%1x" == "x" goto :EOF
@if NOT EXIST %TEMPF1% goto NOFILE
@if NOT EXIST %TEMPF2% goto NOBAK
@REM echo Checking %TEMPF1%
@set /A TEMPC+=1
@goto :EOF

:REVIT
@set TEMPF1=%1
@set TEMPF2=%1.bak
@if "%1x" == "x" goto :EOF
@if NOT EXIST %TEMPF1% goto NOFILE
@if NOT EXIST %TEMPF2% goto NOBAK
@REM echo Checking %TEMPF1%
@copy %TEMPF2% %TEMPF1% >nul
@set /A TEMPD+=1
@goto :EOF


:NOFILE
@echo ERROR: %TEMPF1% file is missing!
@pause
@goto :EOF

:NOBAK
@echo ERROR: No BAK file %TEMPF2%
@pause
@goto :EOF


:NODIR
@echo.
@echo ERROR: Directory [%TEMPD%] does NOT exist...
@echo.
@goto END

:END
