Tech Support Guy banner

Deleting in DOS

2203 Views 16 Replies 10 Participants Last post by  plejon
Is there a way to remove a directory from dos without deleting its content first?
Not open for further replies.
1 - 17 of 17 Posts
Sure: DELTREE [directory path]

"[directory path]" is the location of the directory you want to delete as in DELTREE C:\TEMP. If it is on the root C:\ you can simply type DELTREE TEMP and it will work. Just to avoid problems make sure you are at the root prompt (C:\>) before you enter this command. I am not sure if it works on older DOS versions, however.

It all depends on the DOS version. DELTREE was introduced with DOS 6....before that, you had to first delete all the files and then remove the directory (RD)
Im using whatever windows xp uses for the command prompt.
In that case, I would think DELTREE should be available. However, I'm not that familiar with XP and what it uses with the command prompt. Perhaps someone else will know....
I tried using deltree, but it says that its not a recognised internal or exteernal command. That probably means that it either cant find the command (unlikely) or the command is an external command and isnt on the computer. If this is the case is it possible to download external commands?
You can down load the 6 version but it probably won't work on XP. External Dos commands are pretty hung up on having the correct Dos version running. It would most likely give you an wrong DOS version error if you tryed to run it.
I have got 6.22 and im going to reinstall XP anyway. If i install dos first, will it cause problems because dos uses the fat32 file system and XP uses ntfs.
Actually, DOS 6.22 uses the FAT 16 file system, and won't even work on FAT 32
smeg. is there a newer version of doss than that?
DOS 7 (included with Windows 9x) recognizes FAT32, but I doubt that DOS 7 applets would work with XP.
Windows XP has no true underlying DOS at all.

The "Command Prompt" available is actually a Windows emulation of DOS.

Accordingly you may have some issues depending what you are trying to do at the command prompt.
If you run the command prompt in XP and type help it will give you a list of all the commands it supports... Try RD or RMDIR. Type "RD /?" minus the quotes to get the syntax for the command.
The best thing to do would be to boot off of dos disk and run your commands from there.

you can get a file to make a dos boot disk from
just click the "DOS 6.22" link, download the file and then put a blank floppy in your disk drive. go to the file you downloaded and run it. It will write to the floppy. when it is done you have a DOS boot disk. with deltree on it
Since NT4 Windows has supported the /s switch on the rd (remove directory) command allowing the removal of a non-empty directory.
There is a DELTREE in Dos 7. You can use that.
It is DELTREE /Y <directory>
I put it in a batch file with MD <directory> and put the batch file in the Startup folder.
The following command replaces deltree within XP:

rmdir <dirname> /s or
rd <dirname> /s

This command deletes directories containing files and subdirectories. For more information, just type rd /? in an XP dos box.

So there's no need for deltree anymore
1 - 17 of 17 Posts
Not open for further replies.