General discussion

Locked

Batch file for Search & Delete

By Link999 ·
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.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Batch file for Search & Delete

by D_V Ant In reply to Batch file for Search & D ...

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.

Collapse -

Batch file for Search & Delete

by Link999 In reply to Batch file for Search & D ...

Poster rated this answer

Collapse -

Batch file for Search & Delete

by seandurcan In reply to Batch file for Search & D ...

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.

Collapse -

Batch file for Search & Delete

by Link999 In reply to Batch file for Search & D ...

Poster rated this answer

Collapse -

Batch file for Search & Delete

by JackOfAllTech In reply to Batch file for Search & D ...

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

Collapse -

Batch file for Search & Delete

by Link999 In reply to Batch file for Search & D ...

Thanks to all that answered. The Sweep program was exactly what I needed. My batch file is now searching & deleting :-)

FYI... I was able to download a copy of Sweep from the following site: http://members.cox.net/dos/batch02.htm

Thanks once again !!!

Collapse -

Batch file for Search & Delete

by Link999 In reply to Batch file for Search & D ...

This question was closed by the author

Back to Desktop Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums