Solved

Deleteing Empty subfolders with a Batch File

Posted on 2008-10-21
2
433 Views
Last Modified: 2010-04-21
Is there a simple way to use a batch file to delete an empty subfolder? I can delete all of the contents within a folder but I can't seem to delete the leftover empty folder.
0
Comment
Question by:Joseph Moody
2 Comments
 
LVL 20

Accepted Solution

by:
edster9999 earned 500 total points
ID: 22770792
There used to be a nice command in DOS called deltree
But it was removed a few years ago.

the code was put into rmdir
if you use the /s and /q

This will then delete a full directory and all its contents and then the directory itself.

You might need to put double quotes round the dir name or the variable you are using if the directory name (or parent ones) have spaces in them.
0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 31508466
Thanks! I learn something new everyday!
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question