Discussion Locked

Batch file for Search & Delete

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to create a batch file that will search for, and delete, folders on a hard drive.

For example, say I had three folders called "HAPPY". Something like this:

1) c:\My Documents\Happy\
2) c:\Windows\System32\Happy\
3) c:\My Music\Rock\Happy\

I need a batch file that would be run from the root of "C:\" that would find and delete all three of the "Happy" folders.

It has to be a BATCH file. It has to be able to run from within DOS.

7 replies

by d_v ant

The following will work. I have not been able to figure out how to make it search for a folder named "Happy", but as long as the folders are always in the same place, just substitue the path shown for the folders actual locations.

rd /S /Q C:\Mydocu~1\Happy
rd /S /Q c:\Windows\System32\Happy\
rd /S /Q c:\MyMusi~1\Rock\Happy\

the /S remavoes all directories and files in the folder and the /Q will stop it from prompting you for confirmation.
You must use the short filename. To determine what the short name is, from a command prompt, run the command dir /X in the parent directory and it will display the short filname for you.

Hope this helps.

by seandurcan

Norton used to have a utility which could find the directory by typing NCD HAPPY. Apart from that, you'd be on a hiding to nothing on a "Seek and Destroy" mission. DOS is extremely basic and not really User friendly.

by jackofalltech

This could be done strictly in batch but it would be a royal pain. An easier way is to get the free utility SWEEP (sorry, no URL) and then the batch file would be

@Echo Off
CD \
Sweep DelTree /Y happy

Ralph

This discussion is closed to new replies.