Discussion Locked

Delete command in a batch file?

0 helpful
12 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a batch file I built with NotePad in Win95 and one of the commands is "del f:\slik-app\data\*.*"

The batch runs fine except that this command requires a confirmation. I am using this as part of an automated process. I need to figure out what is needed in the batch so it does not ask for confirmation.

Any ideas/answers???

12 replies

by yorkster

use a /Q at the end of your delete statement, the Q is for quite mode.
hope this helps
note: this works in NT but I'm not sure about 95

by syscokid

1. Create a text file that contains only the letter "y". Call it y.txt.

2. Change your command to del f:\slik-app\data\*.*

by jim_rau

I remember this ... thanks for the refresher but the echo is a better solution (see below).

by james schroer

Try a del /y f:\slik-app\data\*.* or try del f:\slik-app\data\*.* /y If that doesn't work I know for a fact this will. You will have to delete the directory but it will create the directroy back. deltree /y f:\slik-app\data
if not exist f:\slik-app\data\nul md f:\slik-app\data

by jim_rau

So I would have to add more lines to put the folder back ... but the echo idea below is much better and the one above is OK too ...

by syscokid

I know for a fact mine works, but I think you might need a hard return after the letter y.

by jeng

Comment on #1: DEL F:\slip-app\data /y only works for NT

On #2: This will work. You can bypass the creation of a "Y" file by doing "echo Y | DEL F:\slip-app\data". This will work with any version of DOS (of at least DOS 5.0).

On #3: Becareful with DELTREE. It will do the deletion, but it will take out the subdirectories below it. After deleting the files, it will remove the subdirectory "F:\slip-app\data" itself. This is only available in Win9x. For NT, use "RD /S /Y"

by jim_rau

You the MAN! What is best about this is I don't need a text file to implement the idea, it kind of works wherever it is. Thanks!!!

by al hedstrom

You need The Pipe:

echo y | del c:\temp\*.*

The character after the Y, pipe, is located above the backslash on my keyboard (yours may be different).

This technique temporarily puts a "Y" in the keyboard buffer and feeds it back the next time DOS expects keyboard input - in this case, confirmation that you really know what you're doing when you delete all files.

Hope this helps.

Al Hedstrom

by jim_rau

Right answer but a bit slower than Al (sorry). Thanks for the time though ...

This discussion is closed to new replies.