Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I remove all folders and sub folders containing SQ00 in their name from the command-prompt?

share|improve this question

First go to the path where you would want to originate the search/delete.

cd c:\temp

Then type the following:

for /f %i in ('dir /a:d /s /b *sq00*') do echo rd /s /q %i

When you see the output and you are comfortable it would delete the folder(s) you see, you can remove the echo and actually run the command like this:

for /f %i in ('dir /a:d /s /b *sq00*') do rd /s /q %i

dir /a:d /s /b *sq00* looks through the directory tree where you originate the command (current directory!) and all subfolders matching folders including the string sq00. /a:d means it only looks for directories, /s means it looks recursively, /b means "bare" format excluding headers/etc.

For each result it finds with dir, it puts it in the variable %i and then runs the command rd /s /q %i on it. rd deletes folder (short for rmdir), and the flags /s means that it removes the folder and all subfolders, and finally /q means it is quiet and won't ask any questions.

share|improve this answer

Using the SFUA utility toolkit:

This can be done using the find command that is in Microsoft's SFUA utility toolkit, that runs in the Subsystem for Unix-based Applications:

find . -type d -name '*sq00*'|xargs rm -r --
Of course, this deletes all of the subdirectories of the *sq00* directories.

Using JP Software's TCC/LE:

This is a simple exercise in the use of the ordinary for command to find the directories matching the name and the del command to delete their contents:

for /r /d %dir in (*sq00*) do del /s/x %dir\*
Turning off prompting, not deleting the subfolders of the folders found, including system and hidden files, or choosing whether or not to delete to the Recycle Bin are all exercises in the various options (such as /y) to the del command.

Using Microsoft's command interpreter:

As in Mattias Ahnberg's answer.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .