Solved

BATCH FILE FOR REMOVING A COMMON DIRECTORY NAME

Posted on 2015-01-08
6
148 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 23

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 23

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 23

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 23

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

861 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

25 Experts available now in Live!

Get 1:1 Help Now