Delete file based on input

February 14, 2012 at 18:09:44
Specs: Windows Vista
I am trying to write a batch file to delete a file within a specific directory based on a file the user puts in. So if the file Helloworld.txt is in the directory C:\Users\Users\Desktop. A user can type the file Helloworld.txt and it will be deleted.

The script I have right now is


set input=
set /p input= Choice:
if EXIST C:\Users\User\Desktop\Server\Plugins\%input% del
pause
exit


Anyone have solutions?


See More: Delete file based on input

Report •

#1
February 15, 2012 at 08:42:47
please test

%echo off
cls
echo PLEASE ENTER A FILE NAME WITH EXTENSION(EG: helloworld.txt)

:starts
set /p input= Choice:
if EXIST C:\Users\User\Desktop\Server\Plugins\%input% del C:\Users\User\Desktop\Server\Plugins\%input% && GOTO complete
echo invalid choice, please make another
goto starts

:complete
echo THANKYOU! please type ENTER to end
pause
exit

mike


Report •
Related Solutions


Ask Question