Hi, I want to create a batch file, in this batch file I want to be able to type delete, then a message pops up saying Enter File Path:, now ths is where im stuck, when the person puts in c:/users/docs/myfile.txt, I want it to be deleted, the code I have is
@echo off
title Command Prompt
color a
A:
set input=
set /p input=input:
if %input%==delete goto b
:b
set input=
set /p input=Enter File Path:
goto A
but I need it to be able to rememeber what has being typed in before so I can add the code del *********** /f, with the ********* as what ever the file path typed in was
Thanks for reading
Ben
Remembering last entry
Moderator: DosItHelp
Re: Remembering last entry
Its the same like before. What you typed in is saved in variable %input% and the command line you need is
del /f "%input%"
I enclosed it in double quotes because of possible spaces in your entered path.
Have a look at this:
Regards
aGerman
del /f "%input%"
I enclosed it in double quotes because of possible spaces in your entered path.
Have a look at this:
Code: Select all
@echo off
title Command Prompt
color a
:A
set "input="
set /p "input=input: "
if /i "%input%"=="delete" goto b
goto A
:b
set "input="
set /p "input=Enter File Path: "
if exist "%input%" (
del /f "%input%"
goto A
) else (
echo File Not Found
goto b
)
Regards
aGerman
Re: Remembering last entry
Thanks a lot
This works perfectly
Cheers
This works perfectly
Cheers