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官方文档


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM