Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete files recursively

Tags:

windows

cmd

I have the directory structure /foo/bar/fooBar/.. . I want to write a Windows command where I can mention the path till foo directory and it deletes all the files and directory recursively in /foo, but it should NOT delete the foo directory.

I have been using rmdir /q /s [path to foo] but this command deletes the foo directory as well. Let me know if there is any command(s) to accomplish this.

like image 721
Akshay Avatar asked Jan 21 '11 06:01

Akshay


People also ask

How do I remove a specific file from subdirectories in Linux?

You can use "find" command with "delete" option. This will remove files with specified name in current directory and sub directories.

How do I delete multiple files in Linux?

To delete multiple files at once, simply list all of the file names after the “rm” command. File names should be separated by a space. With the command “rm” followed by multiple file names, you can delete multiple files at once.


1 Answers

rd /s /q /path/to/foo md /path/to/foo 
like image 193
Ferruccio Avatar answered Sep 28 '22 01:09

Ferruccio