Computer Hope

Microsoft => Microsoft DOS => Topic started by: kordi on October 14, 2008, 02:42:37 PM

Title: Help!!! How Do I Delete All folder From A Directory
Post by: kordi on October 14, 2008, 02:42:37 PM
I have a problem deleting all folders in a directory.The only way i found is to use  rd /s [Name Of Folder],but i want to delete all folders at once... I tried rd /s *.* & rd /s * but that  did not worked.The same with del command.   :P Sorry For My Bad English  :P  Waiting for your help...Ty
Title: Re: Help!!! How Do I Delete All folder From A Directory
Post by: Sidewinder on October 15, 2008, 04:49:28 AM
Code: [Select]
rd /s [Name Of Folder]

That is the correct format to use. Specifically what did you use for name of folder?

Quote
but i want to delete all folders at once

What result did you get?

Note: Expect incorrect results if you're logged-in to any directory within the named folder tree structure.

 8)
Title: Re: Help!!! How Do I Delete All folder From A Directory
Post by: kordi on October 15, 2008, 09:13:40 AM
First of all i want to thank you,for replying in my post.Now if  i have a folder named Folder1  i  write rd /s Folder1.With this way i delete the folder and all the subfolders contains in it.My problem is  if i have in a folder other 10 folders.How can i delete these 10 folders all at once???(I don't want to delete the first folder,i want to enter to first folder and then delete everything that is in it. Waiting....
Title: Re: Help!!! How Do I Delete All folder From A Directory
Post by: kordi on October 15, 2008, 09:22:41 AM
In order to give you understand i'll give you an other example.If i want to delete all the files a folder contains i write del /q *.*  .Now with rd what should i write instead of *.*????
Title: Re: Help!!! How Do I Delete All folder From A Directory
Post by: Sidewinder on October 15, 2008, 12:33:14 PM
Quote
I don't want to delete the first folder,i want to enter to first folder and then delete everything that is in it

That was an important piece of information.

Code: [Select]
@echo off
for /f "tokens=* delims=*" %%i in ('dir /s /b /a-d folder1') do (
del /f %%i
)
for /f "tokens=* delims=*" %%i in ('dir /s /b /ad folder1') do (
rd /s /q %%i
)
   
Note: You should use a fully qualified path to folder1. The code is written as a batch file to be run from the command prompt.
   
Title: Re: Help!!! How Do I Delete All folder From A Directory
Post by: kordi on October 15, 2008, 03:06:41 PM
I will look for what this loop does.Now i can't understand exactly.I will look for it and you will have my reply if i accomplished it.