@echo off
title Saved state list
cd ..
if not exist .\save goto done
if not exist .\save\1 goto done
if not exist .\save\2 goto done
if not exist .\save\3 goto done
if not exist .\save\4 goto done
if not exist .\save\5 goto done
if not exist .\save\6 goto done
if not exist .\save\7 goto done
if not exist .\save\8 goto done
if not exist .\save\9 goto done
if not exist .\save\10 goto done
cd save
set name=Program Name
goto reset_all

:reset_all
set me=
set not_found=0
set total=0
goto home

:home
cls
echo Saved state list
echo ================
if exist ".\1\%name%" type ".\1\%name%" && echo 		(Slot 1)
if not exist ".\1\%name%" echo None		(Slot 1) && set /A not_found+=1
if exist ".\2\%name%" type ".\2\%name%" && echo 		(Slot 2)
if not exist ".\2\%name%" echo None		(Slot 2) && set /A not_found+=1
if exist ".\3\%name%" type ".\3\%name%" && echo 		(Slot 3)
if not exist ".\3\%name%" echo None		(Slot 3) && set /A not_found+=1
if exist ".\4\%name%" type ".\4\%name%" && echo 		(Slot 4)
if not exist ".\4\%name%" echo None		(Slot 4) && set /A not_found+=1
if exist ".\5\%name%" type ".\5\%name%" && echo 		(Slot 5)
if not exist ".\5\%name%" echo None		(Slot 5) && set /A not_found+=1
if exist ".\6\%name%" type ".\6\%name%" && echo 		(Slot 6)
if not exist ".\6\%name%" echo None		(Slot 6) && set /A not_found+=1
if exist ".\7\%name%" type ".\7\%name%" && echo 		(Slot 7)
if not exist ".\7\%name%" echo None		(Slot 7) && set /A not_found+=1
if exist ".\8\%name%" type ".\8\%name%" && echo 		(Slot 8)
if not exist ".\8\%name%" echo None		(Slot 8) && set /A not_found+=1
if exist ".\9\%name%" type ".\9\%name%" && echo 		(Slot 9)
if not exist ".\9\%name%" echo None		(Slot 9) && set /A not_found+=1
if exist ".\10\%name%" type ".\10\%name%" && echo 		(Slot 10)
if not exist ".\10\%name%" echo None		(Slot 10) && set /A not_found+=1
echo.
set /A total=10-%not_found%
echo Total: %total% slot(s)
echo.
if %not_found% == 10 echo No save slot to remove. Press any key to exit... && pause >nul && goto done
if NOT %total% == 1 echo Enter A to remove all slots.
set /p me=Enter a slot number to remove: 
if /I "%me%" == "a" goto remove_all
if "%me%" == "" goto reset_all
if not exist "%me%\Program Name" goto error_1
del /f /q .\%me%\* >nul
if exist ".\%me%\Program Name" goto unknown_err
echo.
echo Done.
pause >nul
goto reset_all

:remove_all
del /f /q .\1\* >nul
del /f /q .\2\* >nul
del /f /q .\3\* >nul
del /f /q .\4\* >nul
del /f /q .\5\* >nul
del /f /q .\6\* >nul
del /f /q .\7\* >nul
del /f /q .\8\* >nul
del /f /q .\9\* >nul
del /f /q .\10\* >nul
if exist ".\1\Program Name" goto unknown_err
if exist ".\2\Program Name" goto unknown_err
if exist ".\3\Program Name" goto unknown_err
if exist ".\4\Program Name" goto unknown_err
if exist ".\5\Program Name" goto unknown_err
if exist ".\6\Program Name" goto unknown_err
if exist ".\7\Program Name" goto unknown_err
if exist ".\8\Program Name" goto unknown_err
if exist ".\9\Program Name" goto unknown_err
if exist ".\10\Program Name" goto unknown_err
echo.
echo Done.
pause >nul
goto reset_all

:error_1
if not "%me%" == "1" goto reset_all
if not "%me%" == "2" goto reset_all
if not "%me%" == "3" goto reset_all
if not "%me%" == "4" goto reset_all
if not "%me%" == "5" goto reset_all
if not "%me%" == "6" goto reset_all
if not "%me%" == "7" goto reset_all
if not "%me%" == "8" goto reset_all
if not "%me%" == "9" goto reset_all
if not "%me%" == "10" goto reset_all
echo Empty slot : %me%.
pause >nul
goto reset_all

:unknown_err
echo.
echo Unknown error! Couldn't remove one or more save slot(s) you specified.
echo If you are currently running DOSBox, close it and try again.
pause >nul
goto reset_all

:done
set me=
