PC Review


Reply
Thread Tools Rate Thread

HOW TO CLEAN A FOLDER CONTENT USING CMD

 
 
EziContact1
Guest
Posts: n/a
 
      18th Jan 2005
Hello all

can any one help?

I need to clean few folders using a batch file ..but I couldn't find a
way to delete subdirectories (Without deleting Root folder)

Eg:
if we have this tree:
C:\Folder1\folder2\files 1 2 3 etc
C:\Folder1\folder3\files 1 2 3 etc
C:\Folder1\folder4\folder5\files 1 2 3 etc
C:\Folder1\files 1 2 3 etc

I need to del (erase everything in "C:\Folder1" without deliting
folder1)

At the moment I use (RD "C:\Folder1" ~~ and MD "C:\Folder1")but it has
some side effects.

Thank you all for help...

 
Reply With Quote
 
 
 
 
Matthias Tacke
Guest
Posts: n/a
 
      18th Jan 2005
EziContact1 wrote:
> Hello all
>
> can any one help?
>
> I need to clean few folders using a batch file ..but I couldn't find a
> way to delete subdirectories (Without deleting Root folder)
>
> Eg:
> if we have this tree:
> C:\Folder1\folder2\files 1 2 3 etc
> C:\Folder1\folder3\files 1 2 3 etc
> C:\Folder1\folder4\folder5\files 1 2 3 etc
> C:\Folder1\files 1 2 3 etc
>
> I need to del (erase everything in "C:\Folder1" without deliting
> folder1)
>
> At the moment I use (RD "C:\Folder1" ~~ and MD "C:\Folder1")but it has
> some side effects.
>
> Thank you all for help...
>

A week ago there was a similar question in alt.msdos.batch.nt ;-)
Read my answer:
http://groups.google.com/groups?threadm=crsce5$ne8$04$(E-Mail Removed)

--
Gruesse Greetings Saludos Saluti Salutations
Matthias
---------+---------+---------+---------+---------+---------+---------+
 
Reply With Quote
 
Mark V
Guest
Posts: n/a
 
      18th Jan 2005
In microsoft.public.win2000.cmdprompt.admin EziContact1 wrote:

> Hello all
>
> can any one help?
>
> I need to clean few folders using a batch file ..but I couldn't
> find a way to delete subdirectories (Without deleting Root
> folder)
>
> Eg:
> if we have this tree:
> C:\Folder1\folder2\files 1 2 3 etc
> C:\Folder1\folder3\files 1 2 3 etc
> C:\Folder1\folder4\folder5\files 1 2 3 etc
> C:\Folder1\files 1 2 3 etc
>
> I need to del (erase everything in "C:\Folder1" without deliting
> folder1)
>
> At the moment I use (RD "C:\Folder1" ~~ and MD "C:\Folder1")but
> it has some side effects.


CHDIR *into* the directory (making it the Current Directory),
then issue
RD . /q /s

This will erase all files in the current directory and sub-
directories, all the sub-directories of the current directory.
If will produce a harmless error. If will fail on items currently
in use by another process or if the account has insufficient
permissions to delete. Be as careful with RD /s /q as with the old
DELTREE! See RD /? on your OS to confirm the switches.


 
Reply With Quote
 
Jerold Schulman
Guest
Posts: n/a
 
      19th Jan 2005
On 18 Jan 2005 11:39:24 -0800, "EziContact1" <(E-Mail Removed)> wrote:

>Hello all
>
>can any one help?
>
>I need to clean few folders using a batch file ..but I couldn't find a
>way to delete subdirectories (Without deleting Root folder)
>
>Eg:
>if we have this tree:
>C:\Folder1\folder2\files 1 2 3 etc
>C:\Folder1\folder3\files 1 2 3 etc
>C:\Folder1\folder4\folder5\files 1 2 3 etc
>C:\Folder1\files 1 2 3 etc
>
>I need to del (erase everything in "C:\Folder1" without deliting
>folder1)
>
>At the moment I use (RD "C:\Folder1" ~~ and MD "C:\Folder1")but it has
>some side effects.
>
>Thank you all for help...



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

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search folder consists of Inbox and Folder with Rule based content.How to go to 1st unread? JoeBloggs Microsoft Outlook 0 8th Mar 2011 01:42 PM
Search folder consists of Inbox and Folder with Rule based content.How to go to 1st unread? JoeBloggs Microsoft Outlook Discussion 0 2nd Mar 2011 08:58 AM
Re: WinXP Home and temporary internet files folder and content.ie5 folder ICU Windows XP General 22 22nd Sep 2006 05:52 PM
How to clean the content of a strinbuider object Dan Aldean Microsoft C# .NET 4 16th May 2006 08:01 PM
How do I clean the content of a ListBox control?? =?Utf-8?B?U2hhcm9u?= Microsoft C# .NET 1 17th Nov 2004 09:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:27 AM.