Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.