Computer Hope
Software => Computer programming => Topic started by: Whitebeard1 on May 16, 2013, 11:34:14 PM
-
Hey im not sure how to let the user of a batch file select a file and delete it using batch. My computer keeps getting errors although i cannot find out what i programmed wrong. please help.
-
My computer keeps getting errors although i cannot find out what i programmed wrong. please help.
What errors? Syntax? Logic? You would do yourself a world of good if you posted what you have programmed.
How do you see this working? List the files in a folder and allowing the user to select one for deletion? Allowing the user to manually input the label of the file to be deleted?
8)
-
Well, I want to let the user type in the path of the file and delete it.
-
@echo off
setlocal
set /p file=Enter File Name:
if exist %file% (
echo del %file% && echo %file% has been deleted
) else (
echo Incorrect File Name: %file%
)
I dislike writing destructive scripts, so this script performs a whatif scenario. When you're satisfied remove the first echo instruction from line 6.
8)
-
Thanks alot sidewinder! I had found the mistake i made and i had successfully made this batch file that can dlete files. thx! :)