Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

delete files without prompt

4,147 views
Skip to first unread message

Terry

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
Please excuse this silly post, I do not use batch programming very often and
I forgot how this is done.

I have put the following command in a batch file

del *.*

This command when the batch file reaches it requires a "Y" to continue
Could you please remind me how to make the command continue without the "Y"
entry

Thanking you in advance

--
Find everything you need at: http://www.home-it.com


Timo Salmi

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
In article <V0HG5.7840$NQ4.1...@news2-win.server.ntlworld.com>,
Terry <Te...@Nospam.com> wrote:
:del *.*

:This command when the batch file reaches it requires a "Y" to continue
:Could you please remind me how to make the command continue without the "Y"
:entry

2) Deleting all files without being prompted "Are you sure (Y/N)?"

168498 Sep 22 2000 ftp://garbo.uwasa.fi/pc/ts/tsbat62.zip
tsbat62.zip A collection of useful batch files and tricks, T.Salmi

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

William Allen

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
Terry wrote in message

> Please excuse this silly post, I do not use batch
> programming very often and I forgot how this is done.
>
> I have put the following command in a batch file
>
> del *.*

It's a really bad idea to remove the /Y prompting from this as it
stands, because if you do, the batch becomes a wipe-directory for
any current directory it's executed in - including deleting
itself if it's there! If you run DONTDOIT.BAT with this command
as you ask for it, you'll see something like this output:

C:\WORK\TEST>DONTDOIT
All files in directory will be deleted!
Are you sure (Y/N)?y
Batch file missing

Oops! Goodbye batch and everything else. The feature you want
is ECHO Y | (| =pipe command) to send the (Y)es to the command.
Consider something like:

ECHO Y | DEL C:\specific\path\name\*.* >NUL

(the >NUL silences the waring and over-ride y report). If you
don't do it this way, you'll probably eventually regret not doing
so.

--
William Allen

Terry

unread,
Oct 16, 2000, 3:00:00 AM10/16/00
to
Thanks for your response William. That's just what I was looking for.

Timo, I do appreciate your response too although I prefer not to download
programs from websites to find an answer..

--
Find everything you need at: http://www.home-it.com

"William Allen" <ma...@mayfly13.fsnet.co.uk> wrote in message

Todd Vargo

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
Terry <Te...@Nospam.com> wrote in message
news:KNIG5.8122$NQ4.1...@news2-win.server.ntlworld.com...

> Thanks for your response William. That's just what I was looking for.
>
> Timo, I do appreciate your response too although I prefer not to download
> programs from websites to find an answer..

If you have any interest to learn batch file commands, I highly recommend
that you download Timo's zipped list of FAQ's etc. which include the replies
found here.

--
Todd Vargo (body of msg must contain my name to reply)


James A. Coons

unread,
Nov 3, 2000, 1:33:48 AM11/3/00
to
Terry wrote:

> Please excuse this silly post, I do not use batch programming very often and
> I forgot how this is done.
>
> I have put the following command in a batch file
>
> del *.*
>

> This command when the batch file reaches it requires a "Y" to continue
> Could you please remind me how to make the command continue without the "Y"
> entry
>

> Thanking you in advance


>
> --
> Find everything you need at: http://www.home-it.com

(Command Line)
FOR %F IN (*.*) DO DEL %F

(in Batch File)
FOR %%F IN (*.*) DO DEL %F%

James Coons

laura fairhead

unread,
Nov 3, 2000, 6:37:30 AM11/3/00
to

-------------------------^^^ !!should be %%F

In DOS7;
FOR %%F IN (*.*) DO DEL %%F

Works on both the cmd line and in a batch.
DOS5 won't allow this, I don't know about DOS6...

Bye

L

>James Coons
>

Outsider

unread,
Nov 3, 2000, 9:06:20 AM11/3/00
to

In 6.22, one % at the command line and two % in a batch.


--
Outsider
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Navigator 4.08

Erik Hegeman

unread,
Nov 4, 2000, 3:00:00 AM11/4/00
to
You can also use the following command:

echo y | del *.* >NUL

This way you won't have to enter Y, and you won't see the 'Are you sure'
text on your screen. This command will just clean a directory without
writing anything on the screen and without asking you questions.

I hope this will be of help, Erik Hegeman.

James A. Coons <jac...@ameritech.net> schreef in berichtnieuws
3A025C4C...@ameritech.net...

James A. Coons

unread,
Nov 4, 2000, 3:00:00 AM11/4/00
to
Outsider wrote:

(my mistake - type. Command Line is %F and batch file is %%F.

James Coons


laura fairhead

unread,
Nov 4, 2000, 10:53:22 PM11/4/00
to
On Sat, 04 Nov 2000 14:44:08 -0800, "James A. Coons" <jac...@ameritech.net> wrote:

> (my mistake - type. Command Line is %F and batch file is %%F.
>
> James Coons
>

Actually I wonder just how they have implemented this; the major
change in DOS7 interactive mode of parsing the command line
for variables is syntactically ambiguous if you still allow
a single % to represent replaceable parameters.

The way the line is parsed is really weird;

FOR %P IN (1) DO ECHO %PATH%P

ECHO's the variable %PATH% followed by a 'P'

FOR %P IN (1) DO ECHO %PATH_%P

ECHO's "1ATH_1"

There are lots of complications to this,
I bet the code for DOS7 is absolutely hideous....

Bye,

L

mar...@gmail.com

unread,
Nov 5, 2014, 6:58:25 AM11/5/14
to
On Monday, 16 October 2000 08:00:00 UTC+1, William Allen wrote:
> Terry wrote in message
> > Please excuse this silly post, I do not use batch
> > programming very often and I forgot how this is done.
> >
> > I have put the following command in a batch file
> >
> > del *.*
>
> It's a really bad idea to remove the /Y prompting from this as it
> stands, because if you do, the batch becomes a wipe-directory for
> any current directory it's executed in - including deleting
> itself if it's there! If you run DONTDOIT.BAT with this command
> as you ask for it, you'll see something like this output:
>
> C:\WORK\TEST>DONTDOIT
> All files in directory will be deleted!
> Are you sure (Y/N)?y
> Batch file missing
>
> Oops! Goodbye batch and everything else. The feature you want
> is ECHO Y | (| =pipe command) to send the (Y)es to the command.
> Consider something like:
>
> ECHO Y | DEL C:\specific\path\name\*.* >NUL
>
> (the >NUL silences the waring and over-ride y report). If you
> don't do it this way, you'll probably eventually regret not doing
> so.
>
> --
> William Allen

great post thanks again William

Kerr Mudd-John

unread,
Nov 5, 2014, 8:29:28 AM11/5/14
to
On Wed, 05 Nov 2014 11:58:25 -0000, <mar...@gmail.com> wrote:

> On Monday, 16 October 2000 08:00:00 UTC+1, William Allen wrote:
>> Terry wrote in message
>> > Please excuse this silly post, I do not use batch

[]

>>
>> --
>> William Allen
>
> great post thanks again William

Wherever you are. 14 years later!

--
Bah, and indeed, Humbug

Batchman

unread,
Nov 30, 2014, 6:56:22 PM11/30/14
to
mar...@gmail.com wrote:

>> > I have put the following command in a batch file
>> >
>> > del *.*
>>

Another method to delete all files without prompt is to CD into the correct
folder and then...

FOR %%f IN (*.*) DO DEL %%f

This loop uses the DEL command to delete each file individually.

WARNING you must ensure that your batch file uses a CD (Change Directory)
command to make the default directory the correct one before using the FOR
loop line above!

Batchman

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Todd Vargo

unread,
Dec 1, 2014, 1:45:01 AM12/1/14
to
On 11/30/2014 6:53 PM, Batchman wrote:
> mar...@gmail.com wrote:
>
>>>> I have put the following command in a batch file
>>>>
>>>> del *.*
>>>
>
> Another method to delete all files without prompt is to CD into the correct
> folder and then...
>
> FOR %%f IN (*.*) DO DEL %%f
>
> This loop uses the DEL command to delete each file individually.
>
> WARNING you must ensure that your batch file uses a CD (Change Directory)
> command to make the default directory the correct one before using the FOR
> loop line above!
>
> Batchman

Brilliant! So if your batch file uses a CD to a directory that does not
exist, all files in whatever directory happens to be current will be
deleted without question.

I advocate that if you know path to the directory that you want to make
current, then either place that path in the DEL or in the FOR command.

DEL c:\path-to\*.*

or

for %%f in (c:\path-to\*.*) do del %%f

Wildcard deletes based on whatever directory is current is a sure fire
path to disaster. You have been warned.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Batchman

unread,
Dec 1, 2014, 6:58:55 PM12/1/14
to
Todd Vargo wrote:

> Brilliant! So if your batch file uses a CD to a directory that does not
> exist, all files in whatever directory happens to be current will be
> deleted without question.

Well what could be done initially is...

If NOT exist c:\targetdir\nul goto Quit

OR

If NOT exist c:\targetdir\*.* goto Quit
>
>
> DEL c:\path-to\*.*
>
> or
>
> for %%f in (c:\path-to\*.*) do del %%f

Of course, including the target folder is the easiest way to ensure that on
the files to be deleted will be removed.

foxidrive

unread,
Dec 1, 2014, 8:37:14 PM12/1/14
to
On 2/12/2014 10:55, Batchman wrote:

Hi Batchman :)

> Well what could be done initially is...
>
> If NOT exist c:\targetdir\nul goto Quit

The NT way of doing this doesn't use nul, coz it no longer works properly:

If NOT exist "c:\targetdir\" goto Quit


Just commenting here that double quotes are needed around %%f to handle any filenames with spaces
etc, and also around the path for the same reason.


for %%f in ("c:\path-to\*.*") do del "%%f"

Batchman

unread,
Dec 2, 2014, 4:25:26 AM12/2/14
to
foxidrive wrote:

> On 2/12/2014 10:55, Batchman wrote:
>
> Hi Batchman :)

'lo Foxi, I knew I'd bump into you b4 long ;)

Things are quiet in the other place without you.
>
>
> The NT way of doing this doesn't use nul, coz it no longer works properly:
>
> If NOT exist "c:\targetdir\" goto Quit

Yep, after I sent my original I figured that would be the case.
Trouble is, I come from Command.Com country. We talk different there!
>
>
> Just commenting here that double quotes are needed around %%f to handle
> any filenames with spaces etc, and also around the path for the same
> reason.
>
>
> for %%f in ("c:\path-to\*.*") do del "%%f"

Right again! I can see that I'll need to watch my p's & q's in this
eecchhoo.

Batch

Ilse Prof

unread,
Dec 3, 2014, 2:19:18 PM12/3/14
to
Am Wed, 05 Nov 2014 03:58:25 -0800 schrieb marc28:

> On Monday, 16 October 2000 08:00:00 UTC+1, William Allen wrote:
>> Terry wrote in message
>> > Please excuse this silly post, I do not use batch programming very
>> > often and I forgot how this is done.
>> >
>> > I have put the following command in a batch file
>> >
>> > del *.*
>>
Hi folks,

In DOS 6.22 was the command "deltree". Those were the days. :-))

and since win7 or already in XP?

it gives the "RD" or "RMDIR" command.

This command has new options since 6.22 -> /S and /Q

/S = Removes all directories and files in the specified directory in
addition to the directory itself. Used to remove a directory tree.

/Q = Quiet mode, do not ask if OK to remove a directory tree with /S.

after "RD" you can "MKDIR" your deleted folder ;-)

better geht nicht

>
> great post thanks again William

bye
Ils(e)

Kerr Mudd-John

unread,
Dec 3, 2014, 2:45:41 PM12/3/14
to
On Wed, 03 Dec 2014 19:19:16 -0000, Ilse Prof <ils....@gmx.de> wrote:

> Am Wed, 05 Nov 2014 03:58:25 -0800 schrieb marc28:
>
>> On Monday, 16 October 2000 08:00:00 UTC+1, William Allen wrote:

N.B. 14 years later! I suggest the OP is no longer interested!

>>> Terry wrote in message
>>> > Please excuse this silly post, I do not use batch programming very
>>> > often and I forgot how this is done.
>>> >
>>> > I have put the following command in a batch file
>>> >
>>> > del *.*
>>>
> Hi folks,
>
> In DOS 6.22 was the command "deltree". Those were the days. :-))
>
> and since win7 or already in XP?
>
> it gives the "RD" or "RMDIR" command.
>
> This command has new options since 6.22 -> /S and /Q
>
> /S = Removes all directories and files in the specified directory in
> addition to the directory itself. Used to remove a directory tree.
>
> /Q = Quiet mode, do not ask if OK to remove a directory tree with /S.
>
> after "RD" you can "MKDIR" your deleted folder ;-)
>
> better geht nicht
>
>>
>> great post thanks again William
>
> bye
> Ils(e)


pssre...@gmail.com

unread,
May 7, 2015, 1:24:15 AM5/7/15
to
On Monday, October 16, 2000 at 11:00:00 AM UTC+4, Terry wrote:
> Please excuse this silly post, I do not use batch programming very often and
> I forgot how this is done.
>
> I have put the following command in a batch file
>
> del *.*
>
> This command when the batch file reaches it requires a "Y" to continue
> Could you please remind me how to make the command continue without the "Y"
> entry
>
> Thanking you in advance
>
> --
> Find everything you need at: http://www.home-it.com

TRY

DEL/Q *.*
0 new messages