1.

Solve : Deleting Directories Within Directories and Files?

Answer»

I am trying to learn DOS and I am currently using the website
http://www.robvanderwoude.com/index.html to help me along the way.

I have done a search on these forums to learn about the /del command. Its pretty straight foward.

But I want to expand my knowledge and could not find this anywhere.

I made a folder Called Delete and I placed over 40 files inside of it all containing different extensions. I also made several other directories and serveral files within those directories.

Now, what I need to know is if there is a single line I can type to easily delete all of those directories and the files within it and NOT prompt me.

cd Delete
del *.* /q or /y

I have some folders on PCs on my network that need to be cleared out, like My Documents etc, thats the reason for learning this command. I run a Teaching Course and PEOPLE PUT garbage on these folders all the time.Under pure DOS you can use deltree. But it can be dangerous if you get careless. You don't get second chances.I understand that much.

Can the deltree command work on modern systems like XP?

And what about the "Yes" switch? How can that be accomplished? I do not want 100+ systems asking me if I am sure I want to delete the files, I want an automated Batch.

Ok, I just tried deltree, it is NOT a recognized command. I am using the standard CMD that came with Windows XP on SP2.

So any other advice?

------------
Just to give you guys an idea of what GOES on, kids come onto the systems and download a bunch of files and garbage and then leave them on the system. We need the systems to be clear from that crap, so I am making a batch file that Deletes all files in My Documents.
Deltree is not available at the XP command prompt. Del is the one in XP see here for all the NT COMMANDS.

Good luckWell, I don't want Windows NT commands.

I am back to square one; I need a dos Command, COMPATIBLE with windows XP dos, that deletes all files in a given directory (my documents) and does not prompt a user.

Thanks for advice...

P.s. Would this work: del *.* /y





The Windows NT commands are for use at the Command Prompt, what you call Windows XP Dos.

XP does NOT have Dos just a Dos emulator. The command syntaxes in XP may not be the same as when true Dos is used so you should use the NT command syntax. If you want to see the syntax for Del at the command prompt enter Del/?

If you enter Del *.* at the command prompt it is likely you will delete ALL unprotected files in the current directory. Take care!!

Happy hunting...

I got one part of the problem worked out.

I can successfully delete all files within a root directory without it prompting me.

Using:
del *.* /q
Where q is the switch for "yes".
The other part of the problem is having the other directories within the root delete as well. The del *.* only deletes the files, not directories.You can use rd folderspec /s/q. Keep in mind this will delete the entire directory tree including the directory. There are other ways to do this, but you wanted a one line command.

Be careful.

PS. XP is an NT machine and uses NT commands.So folderspec is the name of the folder? I am guessing it is, lets go try out and see how it works. To delete a directory without been asked :

deltree /y name

Of course, to be used carefully.

But I've also got a difficulty : how to delete all subdirectories without deleting the root?
The following code line wouldn't work :

for %%f in ( *) do deltree /y %%fPierre... What OS are you using???

Quote

Deltree is not available at the XP command prompt. Del is the one in XP see here for all the NT commands.

Good luck



Again.... Deltree is NOT available at the XP Command Prompt. It is neither an internal nor external command for Cmd.exe or Command and therefore cannot be used at the Command Prompt or in a .bat file. It seems you are not familiar with the use of NT Commands, I suggest you familiarise yourself with them before trying to follow the guides in Rob van der Woude's scripting pages. The damage you might do to system files by not understanding NT Commands defies description.

Good luckwhat about the rmdir command


Discussion

No Comment Found