@echo off
pushd %~d0%~p0

setlocal EnableDelayedExpansion

set "_READERNAME=READER"
set "_READERMODEL=PRS-T1  SD"

for /F "usebackq tokens=1" %%a in (`.\ebook_msc.exe name "%_READERMODEL%" getdrv`) do (
   if /I "%%a" NEQ "NONE" (
	  set "DRIVE=%%a"
	  goto :done_looking
   )
)

echo Reader [%_READERNAME%] not found
echo.
.\ebook_msc.exe listdrv
echo.
set /p DRIVE="Enter the letter of the Reader drive? "
if errorlevel 1 goto :failure

:done_looking

set "DRIVE=%DRIVE:~0,1%"
vol %DRIVE%:
if errorlevel 1 goto :failure

set /p "ANSWER=Continue? <Y/N> "

if /I "%ANSWER%" NEQ "Y" goto :failure

rem set /p DRIVE=Enter the letter of the Reader drive?
rem if errorlevel 1 goto :failure

rem goto :nocopy-epub

if not exist .\"OS Firmware" goto :nocopy-jail

rem if exist %DRIVE%:\"OS Firmware" goto :nocopy-jail

xcopy .\"OS Firmware" %DRIVE%:\"OS Firmware" /E /C /R /H /I /K /Y 
if errorlevel 1 goto :failure

:nocopy-jail

.\ebook_msc.exe name "%_READERMODEL%" um recovery
if errorlevel 1 goto :failure

pause
popd 
goto :eof

:failure
echo Script did not complete
pause
popd 

