Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Remove-item recursive

$
0
0

How do you delete all the txt files from one folder and all sub folders?

remove-item -Path Logs -Filter *.txt -Recurse

This works but it tries also to delete the subfolders and raises some exceptions

remove-item -Path Logs\* -Filter *.txt -Recurse

This doesn't delete the txt files in the subfolders

remove-item -Path Logs -Include *.txt -Recurse

This does exactly nothing, most probably because the Path has no wildcard

remove-item -Path Logs\* -Include *.txt -Recurse
This doesn't delete the txt files in the subfolders

It seems a simple task, but it doesn't, so I tried all the combinations of path with include and filter but no one really works, what I missing?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>