Rob van der Woude's Scripting Pages

The DEL command

Basic syntax

DEL filespec

filespec:    files to be deleted

Full syntax

MS-DOS and PC-DOS
(incl. Win95's MS-DOS 7)  
as specified under basic syntax
OS/2 Warp as specified under basic syntax, plus some added features
Windows NT 4/Windows 2000 as specified under basic syntax, plus many new features

To delete all files from a directory, you could use:

DEL *.*

DEL will then ask you to confirm that you want to delete all files.

In batch files, this would stop the execution of the batch file and require user interaction, which usually isn't what batch files are intended for.

One way to solve this would be:

ECHO Y | DEL *.*

which will work fine for English DOS versions; for other languages the "Y" needs to be replaced.
So what if you don't know what language will be used for your batch file?
Try this:

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

This solution is completely independent of both operating system and  language!

Related Stuff


page last modified: 2023-01-27; loaded in 0.0052 seconds