Delete Files and Folders Recursively Using Command Prompt

Posted By Keith Dsouza On July 17, 2009 @ 1:19 pm In Tips And Tricks | 8 Comments

One of our readers recently asked a question with regards to deleting files and folders recursively using the command prompt.

I would like to delete all the folders and files in a folder. Like we have an option to delete all the files is "del *" but it will not work for deleting folders like "rmdir *"

The question is similar to a one asked to us earlier where a user wanted to know how to recursively delete certain file types from directories and sub directories [1] using the command prompt.

However when it comes to deleting directories and subdirectories using the command prompt, the regular rmdirdoes not work with a wildcard.

In order to delete all files and folders recursively using the command prompt you will need to run the command;

rmdir /S directoryname

Replace directorynamewith the directory you want to delete.

recursively_delete_folders

Once you run the command you will be prompted whether you want to delete the files or not, if you do not want to see this prompt you can pass the /Q switch to the command, which will then run the command in non-verbose mode.

However you must note that files and folders deleted from the command prompt do not go to recycle bin, they are permanently deleted, so make sure that you really want to delete those files, however if you do delete those files accidentally you can use one of the free software [2]  to recover deleted files [3].


Article printed from Techie Buzz: http://techie-buzz.com

URL to article: http://techie-buzz.com/tips-and-tricks/delete-folders-recursively-using-command-prompt.html

URLs in this post:

[1] recursively delete certain file types from directories and sub directories: http://techie-buzz.com/tips-and-tricks/recursively-delete-files-in-folders-and-sub-folders-using-command-prompt.html

[2] free software: http://techie-buzz.com/tag/freeware

[3] recover deleted files: http://techie-buzz.com/featured/undelete-files-for-free.html

Copyright © 2006-20011 Techie Buzz. All rights reserved.