Loading

Powershell 批量删除指定后缀名的文件(以json 为例)| 如何删除文件而保留文件夹

# 删除指定文件
PS D:\Data\Documents> Remove-Item * -Include *.json -Recurse
# 删除文件而保留文件夹
# 「This example deletes all of the files that have names that include a dot (.) 」
PS D:\Data\Documents> Remove-Item * -Include *.* -Exclude *.md -Recurse
# 删除包含指定字符的文件夹
# 一定要注意加上通配符「*bin*」,否则只会删除bin这样的文件夹
PS D:\Data\Documents> Remove-Item * -Recurse -Include *bin*

注意添加 * 作为路径

参考资料

MS官方文档

posted @ 2021-01-28 21:43  ZXYFrank  阅读(1775)  评论(0编辑  收藏  举报