1.

Solve : How to let the user select a path f a file and delete it in batch?

Answer»

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.Quote

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?

Well, I want to let the user type in the path of the file and delete it.Code: [Select]@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.

Thanks alot sidewinder! I had found the MISTAKE i made and i had successfully made this batch file that can dlete files. thx!


Discussion

No Comment Found