我想删除所有bin和OBJ文件夹强制所有项目重建一切 [英] I want to delete all bin and obj folders to force all projects to rebuild everything
问题描述
我和多个项目的工作,我想递归删除所有文件夹名称为斌或者OBJ。这样的话,我相信所有的项目将重建everyhing(有时是强制的Visual Studio忘记所有关于previous建立的唯一途径)。
I work with multiple projects and I want to recursively delete all folders with the name 'bin' or 'obj'. That way, I am sure that all projects will rebuild everyhing (sometimes it's the only way to force visual studio to forget all about previous builds).
有没有一种快速的方法,而无需编写一个.NET程序来实现(例如与一个bat文件)?
Is there a quick way to accomplish this (with a bat file for example) without having to write a .net program?
推荐答案
这取决于你preFER使用shell。
This depends on the shell you prefer to use.
如果您使用的是Windows上运行cmd shell那么下面应该工作:
If you are using the cmd shell on Windows then the following should work:
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
如果您使用的是bash或zsh的类型的shell(如Windows或大多数Linux / OS X炮弹混帐bash或babun),那么这是一个好得多,更简洁的方式做你想要什么:
If you are using a bash or zsh type shell (such as git bash or babun on Windows or most Linux / OS X shells) then this is a much nicer, more succinct way to do what you want:
find . -iname "bin" | xargs rm -rf
find . -iname "obj" | xargs rm -rf
和这可以减少到一个符合一个OR:
and this can be reduced to one line with an OR:
find . -iname "bin" -o -iname "obj" | xargs rm -rf
如果你正在使用PowerShell的,那么你可以使用这样的:
If you are using Powershell then you can use this:
Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
如下罗伯特·H公司的答案见过 - 只要确保你给他PowerShell的答案信贷,而不是我,如果你选择最多票什么:)
as seen in Robert H's answer below - just make sure you give him credit for the powershell answer rather than me if you choose to up-vote anything :)
这当然会是明智的,无论运行命令你选择一个安全的地方先测试一下吧!
It would of course be wise to run whatever command you choose somewhere safe first to test it!
这篇关于我想删除所有bin和OBJ文件夹强制所有项目重建一切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!