@echo off
if "%OS%" == not "Windows_NT" goto done
chcp 437
color 0a
mode con:cols=80 lines=30
title SAVED STATES MANAGER
for /l %%a in (1,1,10) do if not exist .\common\saved_list_num\%%a goto done
cd ..
if not exist .\save goto done
for /l %%a in (1,1,10) do if not exist .\save\%%a goto done
cd save
set name=Progra~1
goto reset_all

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

:home
cls
echo.
echo SAVED STATES MANAGER
echo.
echo Slot		Name
echo 컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
for /l %%a in (1,1,10) do if not exist ".\%%a\%name%" set /A not_found+=1
for /l %%a in (1,1,10) do ( type ..\TOOLS\common\saved_list_num\%%a && if exist ".\%%a\%name%" ( type ".\%%a\%name%" && echo. ) ELSE echo. )
echo.
set /A total=10-%not_found%
echo Total: %total% slot(s)
echo.
if %not_found% == 10 echo No saved 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%\%name%" goto error_1
del /f /q .\%me%\* >nul
if exist ".\%me%\%name%" goto unknown_err
echo.
echo Done.
pause >nul
goto reset_all

:remove_all
for /l %%a in (1,1,10) do del /f /q .\%%a\* >nul
for /l %%a in (1,1,10) do if exist ".\%%a\%name%" goto unknown_err
echo.
echo Done.
pause >nul
goto reset_all

:error_1
for /l %%a in (1,1,10) do if not "%me%" == "%%a" 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 now and try again.
pause >nul
goto reset_all

:done
set me=
for /l %%a in (1,1,10) do set size_%%a=
