dos command window commands for del?

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

Gordon J. Rattray wrote:
> 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.

--
Shenan Stanley
MS-MVP
--
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html
 

Jerry

Distinguished
Dec 31, 2007
1,812
0
19,780
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

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

"Gordon J. Rattray" <gords@shaw.ca> wrote in message
news:OUxIGIwtFHA.596@TK2MSFTNGP12.phx.gbl...
> 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
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

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 /?.


"Gordon J. Rattray" <gords@shaw.ca> wrote in message
news:OUxIGIwtFHA.596@TK2MSFTNGP12.phx.gbl...
> 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
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

"Gordon J. Rattray" <gords@shaw.ca> wrote:

>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

Distinguished
Apr 7, 2004
217
0
18,680
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

Gordon J. Rattray wrote:
> 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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

Gordon J. Rattray wrote:

> 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




--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.basics,microsoft.public.windowsxp.general (More info?)

On Sun, 11 Sep 2005 14:08:47 -0700 in
microsoft.public.windowsxp.general, Jerry favored us with...
> 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."
 

TRENDING THREADS