Error code message response

February 8, 2009 at 12:18:24
Specs: Windows XP
I have the bat program working with yes and no responses. I am trying to figure out if I click yes and there is nothing to do. I get an error stating that the files were deleted but also that there were no files, which could be confusing. This is the error message and the batch program.

Do you want to delete all files (Y/N)?y
You chose: y
Files deleted. Thank you.
Could Not Find c:\folder\*.mp3

Press any key to continue . . .

@echo off
set drive=c:\folder\*.mp3
SET /P ANSWER=Do you want to delete all files(Y/N)?
echo You chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={n} (goto :no)

:yes
ECHO Files deleted. Thank you.
del %drive%
echo.
pause
cls
exit

:no
ECHO Files not deleted.
echo.
pause
cls


See More: Error code message response

Report •


#1
February 9, 2009 at 06:12:50

@echo off & setlocal
set drive=c:\folder\*.mp3

:loop
set /P ANSWER=Do you want to delete all files(Y/N)?
echo You chose: %ANSWER%
if /I "%ANSWER%"=="Y" goto :yes
if /I "%ANSWER%"=="N" goto :no
echo Wrong answer, Please Reenter
goto :loop

:yes
if not exist %drive% (
echo There is no file to delete...
) else (
echo Files deleted. Thank you.
del %drive%
)
echo.
pause
cls
exit

:no
ECHO Files not deleted.
echo.
pause
cls
exit




Report •

#2
February 9, 2009 at 07:26:00
Thank you!

Report •

Related Solutions


Ask Question