Solved

Delete a specific subfolder that occurs across a directory structure

Posted on 2013-11-11
3
296 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
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now