[英]How to delete all files named as asd.xsd recursively from SVN repository on Windows
[英]How to recursively delete all SVN files using PowerShell
如何使用PowerShell從目錄中刪除所有Subversion文件?
如果您確實只想刪除.svn目錄,這可能會有所幫助:
gci c:\yourdirectory -include .svn -Recurse -Force |
Remove-Item -Recurse -Force
編輯:向gci
添加了-Force
參數以列出隱藏的目錄並縮短了代碼。
Keith是正確的,它需要避免刪除擴展名為.svn的文件,您應該使用?
過濾項目?
。
假設您不想刪除任何可能也具有.svn擴展名的文件:
Get-ChildItem $path -r -include .svn -Force | Where {$_.PSIsContainer} |
Remove-Item -r -force
Microsoft在下面的評論中回應了Keith在MS Connect上打開的建議中的建議! 從PowerShell V3開始,您Where {$_.PSIsContainer}
通往Where {$_.PSIsContainer}
的多余(非常慢)管道,而使用-directory
代替:
gci $path -r -include .svn -force -directory | Remove-Item -r -force
可以從Windows Management Framework 3.0下載Windows 7的PowerShell v3。
除非您要刪除名稱中帶有特定字符串的所有文件,否則stej的答案是正確的。 在這種情況下,您應該使用:
gci "your_path" -include \*"specific_string"\* -Recurse -Force | Remove-Item -Recurse -Force
筆記:
your_path
僅在包含空格或特殊字符的your_path
才需要使用引號。
specific_string
需要用引號引起來,以確保兩個通配符都能被識別,尤其是當字符串包含()
等字符時。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.