I'm trying to delete all files (but not directories) in D:\MyTemp folder, I've tried:
Remove-Item "D:\MyTemp"
Remove-Item "D:\MyTemp\*"
However, when I check, all the files are still there.
What am I missing?
powershell
I'm trying to delete all files (but not directories) in D:\MyTemp folder, I've tried:
Remove-Item "D:\MyTemp"
Remove-Item "D:\MyTemp\*"
However, when I check, all the files are still there.
What am I missing?
Best Answer
Try this:
Found it here: https://superuser.com/questions/150748/have-powershell-get-childitem-return-files-only
To delete all files in the specified directory only (ignoring sub-dirs):