Delete all files from a folder and its sub folders

This can be accomplished using PowerShell:

Get-ChildItem -Path C:\Temp -Include *.* -File -Recurse | foreach { $_.Delete()}

This command gets each child item in $path, executes the delete method on each one, and is quite fast. The folder structure is left intact.

If you may have files without an extension, use

Get-ChildItem -Path C:\Temp -Include * -File -Recurse | foreach { $_.Delete()}

instead.

It appears the -File parameter may have been added after PowerShell v2. If that's the case, then

Get-ChildItem -Path C:\Temp -Include *.* -Recurse | foreach { $_.Delete()}

It should do the trick for files that have an extension.

If it does not work, check if you have an up-to-date version of Powershell


Short and sweet PowerShell. Not sure what the lowest version of PS it will work with.

Remove-Item c:\Tmp\* -Recurse -Force

You can do so with del command:

dir C:\folder
del /S *

The /S switch is to delete only files recursively.


Using PowerShell:

Get-ChildItem -Path c:\temp -Include * | remove-Item -recurse