[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Delete a specific subfolder that occurs across a directory structure

Posted on 2013-11-11
3
Medium Priority
?
309 Views
Last Modified: 2013-11-12
Hi,

I need to be able to delete any folders called 'Downloads' within a set of user directories.

Is it possible to look for any occurence of that folder and delete it with a batch file/script?

Many thanks
0
Comment
Question by:itmtsn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 39638501
This should work...run it in its current form and it should merely display the folder(s) it will remove.
Removing the 'echo' from the last line will cause it to be data destructive, but if it displays the correct folders in the initial test, it sounds like that's what you're after.

@echo off
cd /d c:\users
for /f "tokens=* delims=" %%a in ('dir downloads /s^|find /i "directory of"') do call :process "%%a\Downloads"
goto :eof

:process
set fld=%1
echo rmdir /s /q "%fld:~15% 

Open in new window

0
 

Author Closing Comment

by:itmtsn
ID: 39641013
Many thanks :)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 39641340
Glad I could help - thanks for the grade :^)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Suggested Courses

650 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