Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How to delete a file in DOS. condition is that , suppose i have three files "file1","file1.txt", "file1.dat" ,..i want to delete all files except "file1"( a file without any extension).
Thanks

... this will leave file1 intact
del *.*t
.
.... Posting is provided "AS IS" with no warranties
http://img515.imageshack.us/img515/...
Grrrr... ....more

More likely:
del *.??t
=====================================
If at first you don't succeed, you're about average.M2

Panyam - you advise your o/s is WXP.
Please bear in mind not all dos facilities are available when running under such o/s's, as they tend to provide only a subset of dos.
For native dos, I go with Mechanix's reply, which should have the desired result. Though possibly Mavis's will work as well.
Good Luck - Keep us posted.

All the three files you gave as an example have one thing in common: their extensions all end in the letter "t". Is that something you can rely on? Or is your requirement that you want to delete all files with ANY extension except those files that have no extension? (If that is the case, then the answers given so far will not be useful.)

What Mike Newcombe is saying is that you have no MS-DOS SubSystem, so this should of been in the PROGRAMMING FORUM, not the **-DOS Standalone O/S Forum...

Good grief. It's a simple question about the DEL command. There's no need for any redirecting or wrist-slapping. Besides the answer is the same whether stand-alone dos or command prompt.

It's a simple question, but the answer is not.
Assuming the question is "how do I delete all files except one?" here is one way (which would probably work in all OS from MD-DOS 6 upwards):
md temp
move file temp
del *.*
move temp\file .
rd tempP.S. At this point I am starting to miss the time when I used to write DCL command procedures on DEC's VMS operating system. The above could be done with
DEL *.* /exclude=*.

Yeah, I suppose there's always a complicated way to do something simple. Going that route how about:
ATTRIB +R *.
DEL *.*
ATTRIB -R

DOS interprets
del *.*t
as:
del *.*
Don't take my word for it; try it yourself.
=====================================
If at first you don't succeed, you're about average.M2

... xp command prompt's del *.*t
... will leave any file without an extension ending in "t" intact
... try it!
.
.............................. lol.
... Posting is provided "AS IS" with no warranties
http://img515.imageshack.us/img515/...
Grrrr... ....more

"... xp command prompt's del *.*t
... will leave any file without an extension ending in "t" intact"
Sure. But this is the DOS forum.
=====================================
If at first you don't succeed, you're about average.M2

Hi All ,
Thanks all for your comments. Sorry for the delayed
response. I rarely work in Dos as always i will be in Unix.The issue is resolved how ever some thing like this :
for %%f in (access.???) do @echo del %%f | find "." >>
temp.bat
call temp.bat
del temp.bat

Was the point here to find some kind of Rube Goldberg method to delete files? If so, job well done.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |