How to delete all the files in a folder except read-only files?

后端 未结 3 757
春和景丽
春和景丽 2021-01-20 21:14

I would like to delete all the files and subfolders from a folder except read-only files.

How to do it using powershell?

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-20 21:36

    For reference, this is a bit easier in V3:

    Get-ChildItem -Attributes !r | Remove-Item -Recurse -Force -WhatIf
    

    or the short (alias) version:

    dir -at !r | ri -r -f -wh
    

提交回复
热议问题