dos command window commands for del?

G

Gordon J. Rattray

Hi there,

I am creating a batch file and want to delete everything in a folder using a
dos command.

I want to do it with one or 2 commands. Del does not work, such as "del *.*"

How do I delete all folders within a folder with one dos command?

Thanks,

Gordon
 
S

Shenan Stanley

Gordon said:
Hi there,

I am creating a batch file and want to delete everything in a folder
using a dos command.

I want to do it with one or 2 commands. Del does not work, such as
"del *.*"

How do I delete all folders within a folder with one dos command?

RMDIR /? should help.
 
T

Torgeir Bakken \(MVP\)

Gordon said:
Hi there,

I am creating a batch file and want to delete everything in a folder using a
dos command.

I want to do it with one or 2 commands. Del does not work, such as "del *.*"

How do I delete all folders within a folder with one dos command?
Hi,

See tip 617 in the 'Tips & Tricks' at http://www.jsiinc.com/reghack.htm

DELTREE.BAT "c:\My Test Folder"

To delete files and sub directories under the temp folder:

DELTREE.BAT "%USERPROFILE%\Local Settings\Temp"


Deltree.bat contains:

@echo off
pushd %1
del /q *.*
for /f "Tokens=*" %%i in ('dir /B') do rd /s /q "%%i"
popd
 
B

Bob Harris

Have you tried DEL with the /S option?

For info on the full set of options for any "DOS" command, open a command
prompt, then type the command followed by /?.
 
R

Ron Martell

Gordon J. Rattray said:
Hi there,

I am creating a batch file and want to delete everything in a folder using a
dos command.

I want to do it with one or 2 commands. Del does not work, such as "del *.*"

How do I delete all folders within a folder with one dos command?

Thanks,

Gordon

Use the RD command to remove the folder and all contents then use the
MD command to create a new folder with the same name.

RD myfolder /S /Q
MD myfolder

/S will remove subfolders if they exist.
/Q will suppress the confirmation prompt

Good luck

Ron Martell Duncan B.C. Canada
--
Microsoft MVP
On-Line Help Computer Service
http://onlinehelp.bc.ca

In memory of a dear friend Alex Nichol MVP
http://aumha.org/alex.htm
 
Z

Z

Gordon said:
I am creating a batch file and want to delete everything in a folder using a
dos command.

I want to do it with one or 2 commands. Del does not work, such as "del *.*"

How do I delete all folders within a folder with one dos command?

$ help rmdir
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S
 
S

Stan Brown

Go to bookstore and buy the book Microsoft Windows Command-Line ISBN
0-7356-2038-5 www.microsoft.com/mspress

Or get the same information for free at

%systemroot%\hh.exe Ms-its:%systemroot%\help\ntcmds.chm::/ntcmds.htm

(Copy the above line and paste it in a Start->Run window.)

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DOS command list 10
DELETING FILES - DEL COMMAND 15
Deleting a file 8
DELETE COMMAND 1
remove sub directories and files 2
Command Prompt v. Run Box? 2
Batch FTP 4
Using the DEL command 12

Top