Top 50 DOS Problems Solved: Recursive Delete

Q: What is the quickest way to delete all the files in a sub-directory, plus all the files in any sub-directories inside it, and so on as deep as directories go, along with the sub-directories themselves? In other words how do you delete an entire branch of sub-directories within sub-directories without typing a lot of DEL, CD and RD commands?

A: There is no easy way for DOS to do this unassisted. The nearest any version comes is DR DOS which can delete the files, but not remove the sub-directories themselves. The relevant command is:

XDEL *.* /S

No version of MS-DOS can automatically delete files in sub-directories. To do the job in its entirety you need a third-party tree pruning utility. You can often find these in PD/shareware libraries. Alternatively, commercial disk utilities such as Xtree will do it.

Leaving aside the amazingness of not having recursive delete, I wonder why the DR-DOS folk decided to produce a command which removed the files but not the directories?

4 thoughts on “Top 50 DOS Problems Solved: Recursive Delete

  1. Having used DR-DOS myself back in the days, I vaguely remember that DOS generally didn’t treat files and directories the same. This probably had historical reasons, originally there was no concept of directories in DOS whatsoever. So the commands (and match patterns) were meant to work with files only. Once directories were added the semantics of the commands couldn’t be changes any more and a new set of commands was added, meant to work on directories only – and patterns would still match files only, not directories. It took lots of time to sort out this mess.

  2. Ugh I hated that! These days you can at least use RMDIR somedir /S and it will blow everything away in it. Ye ol ‘del /S’ only removes files that match but leaves the directories behind. I was always partial to 4dos and its much more sane set of commands.

  3. I thought DELTREE did this, but maybe it doesn’t count since it was an external command that shipped with MS-DOS, as opposed to part of COMMAND.COM?

Leave a Reply

Your email address will not be published. Required fields are marked *