Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a directory using the command prompt 2

Status
Not open for further replies.

FoxT2

MIS
Joined
Oct 3, 2003
Messages
143
Location
US
Hello,

Anyone know of a command that can be issued from the CMD command prompt in WinXP that will delete an entire directory that is located in several different directories of a main directory. For example, I have a main directory called BACKUP that contains several other directories such as PAYROLL,FISCAL,PERSONEL,MAINT etc. In each of these subdirectories there is a directory called TEMP with some files in it. I would like to be able to delete all the TEMP directories that are found any place within the BACKUP directory if possible.

Thanks,

FoxT
 
Search in the Backup Directory for Temp.*
Control A for Select all
Delete

pc.gif

Jomama
 
if you want to use the cmd the best possible solution will probably be a batch file to delete the TEMP folder itself in each path you assign. To delete a folder including all subdirectories and files you would use for example. This is non-reversable so make sure the paths are correct.
RD /s /q "C:\Backup\Payroll\Temp"
RD /s /q "C:\Backup\Fiscal\Temp"
RD /s /q "C:\Backup\Personal\Temp" and so on ... just put that in a text file and save as Filename.Bat and choose all files instead of save as a text file so it will save as a batch file
If you want to keep the Temp folder itself but delete all files within the folder and subdirectories you can use
Del /f /s /q "C:\Backup\Payroll\Temp\*.*" as your commands
this will delete all files and leave all folders intact.
This is probably the easiest way you can do it through the CMD window. If you want to use a script let me know and maybe I can come up with something for you.
 
bcastner even came up with something better :) ignore my post
 
Thanks Bcastner, That works great! That is what I was looking for.

FoxT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top