Solved

BATCH FILE FOR REMOVING A COMMON DIRECTORY NAME

Posted on 2015-01-08
6
151 Views
Last Modified: 2015-01-09
Can someone please write a batch file to remove the directory: arch.

This is a common directory name I use for my job folders and I need to remove it and al it's contents from past jobs to gain storage space.

I am using windows 7 pro.

thank you.
0
Comment
Question by:stevedantonio
  • 4
  • 2
6 Comments
 
LVL 24

Expert Comment

by:NVIT
ID: 40538901
e.g. if arch is in...
c:\arch

then in  CMD prompt...

rd /q /s c:\arch

Open in new window


In a RD_Arch.bat file...
@echo off
rd /q /s c:\arch

Open in new window

0
 

Author Comment

by:stevedantonio
ID: 40540278
THIS COMMAND ONLY REMOVES ONE SPECIFIC DIRECTIORY:  rd /q /s c:\arch

CORRECT?

I NEED IT TO SCAN ALL DIRECTORIES AND REMOVE ANY DIRECTORY NAMED "ARCH"

THANK YOU
0
 
LVL 24

Assisted Solution

by:NVIT
NVIT earned 500 total points
ID: 40540378
This will remove only ARCH folders is c:\. Do you need it to search other folders?

@echo off
for /d %%a in ("c:\*arch*") ECHO rd /q /s %%a

Open in new window


To run it for real, remove the ECHO after you've tested it and it looks fine.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 24

Accepted Solution

by:
NVIT earned 500 total points
ID: 40540393
This one searches all folders:

@echo off
for /f "tokens=*" %%a in ('dir /b /s /ad "c:\*arch*"') do ECHO rd /q /s "%%a"

Open in new window


If folders are strictly named ARCH, change it to:
@echo off
for /f "tokens=*" %%a in ('dir /b /s /ad "c:\arch"') do ECHO rd /q /s "%%a"

Open in new window

0
 

Author Closing Comment

by:stevedantonio
ID: 40541201
Thank you for your time and expertise!
0
 
LVL 24

Expert Comment

by:NVIT
ID: 40541209
You're welcome, Steve. Glad it worked for you. Have a nice weekend. Aloha!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

808 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