Index | Syntax | Notes  



DEL--Examples

To delete the CAT.TMP file from the TEST directory on drive C, you can use   either of the following commands: del c:\test\cat.tmp erase c:\test\cat.tmp To delete all the files in a directory named TEST on drive C, you can use either of the following commands: del c:\test del c:\test\*.*

This batch file is tested in Win98 and is not to be used in DOS version 6.22

This batch file contents information about how to:
  1. Create a file which delete it self without displaying an error message.
  2. Create a two lines solution for either CALL or not (i.e. won't return).

  @echo off
  echo exit|%comspec%/kPROMPT n%temp%.\~.bat$_e0'del %%%%0'1A$_rcx$_7$_w0$_q
|debug>nul
  choice /cn''''''''''''''y/n Return back [Y,N]?
  for %%v in (CALL " ") do if exist %temp%.\~.bat if errorlevel 0%%v %%v %te
mp%.\~.bat
  echo Back here :-)

Notes: Whether the user choose to return back to see the message in line num
       5 above (Back here :-) or choose to not return, then the created file
       named %temp%.\~.bat would be deleted.

       About line number 2:
       The 'del %%%%0'1A$_rcx$_7 can be substituted with
           'del %%%%temp%%%%.\~.bat'1A$_rcx$_12

       About line number 3 and 4:
       My first attempt was not a succes, %comspec%/c can't be used here as:
       choice /c''''''''''''''''''n''''''''''''y/n Return back to here[Y,N]?
       for %%v in (Ccall C) do if errorlevel %%v %comspec%/%%v %temp%.\~.bat
       so, it would fail but I wanted to find a solution and I found it. :-)

Links: Here's a link to another page, which also use an EOF character: <1Ah>


The following is tested in Win98:

DEL ????????????
will delete files with a name such as
    XXXXXXXXXXXX  (12 characters, without an extension)
    XXXXXXXX.XXX  (8+3)
    XXXXXXXXX.XX  (9+2) and
    XXXXXXXXXX.X  (10+1)
maybe not a surprise but the above DEL command
will also include this:
    XXXXXXXXXXX   (11 characters, without an extension)
but NOT filenames of 10 characters. Btw. it will also include this:
    XXXXXXXXXXXXXX.XXX
and other (n+3) names will be included... Hmmm, so, I made a table.

Now one could say that he knows all about a simple command
such as the DEL command but both:
DEL ???????????          and
DEL ?????????????        won't follow the same pattern as the
                         previours one.

======================================================================
 A: DEL *    delete all files.
 B: DEL *.*  delete all files.
 C: DEL *.   delete all files without an EXTension.
======================================================================

                     Without an EXT:   EXT of 3 char:   EXT of 2 char:
----------------------------------------------------------------------
 1: DEL ?              1 character
 2: DEL ??             1 or 2 char.
 3: DEL ???            2 or 3 char.
 4: DEL ????           3 or 4                           1+2
 5: DEL ?????          4 or 5          1+3              2+2
 6: DEL ??????         5 or 6          2+3              3+2
 7: DEL ???????        6 or 7          3+3              4+2
 8: DEL ????????       7 or greater    4+3              5+2
 9: DEL ?????????      8 or greater    5+3              6+2
10: DEL ??????????     9 or 10         6+3              7+2
11: DEL ???????????   10 or 11         7+3              8+2 or greater
12: DEL ????????????  11 or 12         8+3 or greater   9+2
13: DEL ????????????? 12 or 13         9+3             10+2
======================================================================

Notis that the above syntax number 8, 9 and 12 can be used to delete a
lot of files, example: number 12 would delete 8+3, 9+3, 10+3 and so...

To be continued... goto sleep
:sleep


-Top- | Syntax | Notes