?
Solved

BATCH FILE FOR REMOVING A COMMON DIRECTORY NAME

Posted on 2015-01-08
6
Medium Priority
?
175 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
[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
  • 4
  • 2
6 Comments
 
LVL 25

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 25

Assisted Solution

by:NVIT
NVIT earned 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Accepted Solution

by:
NVIT earned 2000 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 25

Expert Comment

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

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
Starting up a Project
Suggested Courses

764 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