Delete Files and Folders Recursively Using Command Prompt

by Keith Dsouza | Translate | Print
Friday, 17th Jul 2009 | Share


Share Delete Files and Folders Recursively Using Command Prompt on Twitter Share Delete Files and Folders Recursively Using Command Prompt on Facebook Save Delete Files and Folders Recursively Using Command Prompt To Delicious Favorites Stumble Delete Files and Folders Recursively Using Command Prompt Share Delete Files and Folders Recursively Using Command Prompt on Digg Get Instant Updates as RSS Feeds from Techie Buzz

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 using the command prompt.

However when it comes to deleting directories and subdirectories using the command prompt, the regular “rmdir” does 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 “directoryname” with 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   to recover deleted files.



Share

One Response so far | Share Your Opinions!

  1. Binny V A
    July 17th, 2009 at 1:26 pm #

    In linux, the command to do this is rm -rf folder_name

    Reply to this comment

Leave a Comment

Note: We discourage users from using keywords in their names while posting comments, most of them get caught by spam, also it really would be more fruitful in knowing people who comment by their real name, rather than by using a name no one relates to. In future we reserve the right to delete comments from users using a name other than their own.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>