Delete Windows files recursively in cmd

How to delete files recursively in Windows cmd? I.e. how to delete all files in a folder and its subfolders. Use the del batch command line and the recursive option. The Windows delete command provides this useful option automate the deletion process. For example, if you have a huge amount to delete but need to keep the folder and subfolder’s structure.

How to delete files recursively with Windows cmd from a folder and all its subfolders?

The main option that I suggest using is the deletion confirmation, this way you can control one last time which files are recursively deleted. Please note that the files deleted in recursive mode with the command line are not stored in the Windows Recycle Bin.

Make sure you delete the proper files only. The operation is irreversible.

Delete files in a recursive way from all subfolders

To delete files recursively using the explicit path, without any confirmation prompt, use this command:

del /s "C:\Folder\"

You can also use this variation, without the quotes and without any confirmation prompt,

del /s C:\Folder\

Please note that the quotes are mandatory when the complete path of the folder, or the file, contains spaces.

Delete all files inside a folder recursively with a confirmation prompt

This option is the one I recommend. Indeed, make sure to double check and confirm before all files are deleted.

Please note that this option delete only the text files as we use the *.txt filter.

del /p /s SubFolder_1\*.txt
Delete a Windows file recursively with cmd with a prompt confirmation.

Then a prompt is displayed for the files that match, in alphabetical order:
c:\Folder\SubFolder_1\file (1).txt, Delete (Y/N)?

Delete files recursively without confirmation

To force the deletion with no prompt at all use the delete quiet mode. Useful with a lot of files.

del /q /s SubFolder_2\*.txt
Delete a Windows file recursively with cmd in quiet mode without confirmation.

To conclude, the del /s recursive option is the fastest and easiest way to delete a bunch of Windows files.

Here is how to copy recursively files and folders in cmd with the xcopy command.