windows 在Windows中递归删除具有指定名称的文件夹的命令行工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/521382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Command line tool to delete folder with a specified name recursively in Windows?
提问by opensas
I want to delete every "_svn" in every folder and subfolder...
我想删除每个文件夹和子文件夹中的每个“_svn”...
For example
例如
c:\ proyect1 _svn images _svn banner _svn buttons _svn
Then I run something like
然后我运行类似的东西
rm-recurse c:\proyect1 _svn
And I should get:
我应该得到:
c:\ proyect1 images banner buttons
The ideal thing would be a tiny stand-alone EXE or something like that.
理想的东西是一个很小的独立 EXE 或类似的东西。
--
Thanks Grant, as soon as I posted the question I saw SVNdocumentation about the SVN export command, but I also want to delete the _vti_* folders stuff Visual Studio creates, so I'll also explore the for
solution.
-- 谢谢 Grant,我一发布问题就看到了有关 SVN 导出命令的SVN文档,但我也想删除 Visual Studio 创建的 _vti_* 文件夹,所以我也会探索for
解决方案。
回答by JMD
Similar to BlackTigerX's "for", I was going to suggest
类似于 BlackTigerX 的“for”,我打算建议
for /d /r . %d in (_svn) do @if exist "%d" rd /s/q "%d"
for /d /r . %d in (_svn) do @if exist "%d" rd /s/q "%d"
回答by Cédric Rup
Time to learn some PowerShell;o)
是时候学习一些PowerShell 了;o)
Get-ChildItem -path c:\projet -Include '_svn' -Recurse -force | Remove-Item -force -Recurse
The first part finds each _svn folder recursively. Force is used to find hidden folders. Second part is used to delete these folders and their contents. Remove commandlet comes with a handy "whatif" parameter which allows to preview what will be done.
第一部分递归地找到每个 _svn 文件夹。强制用于查找隐藏文件夹。第二部分用于删除这些文件夹及其内容。Remove commandlet 带有一个方便的“whatif”参数,允许预览将要执行的操作。
PowerShell is available for Windows XP and Windows Vista. It is present on Windows 7 and on Windows Server 2008 R2 by default.
PowerShell 可用于 Windows XP 和 Windows Vista。默认情况下,它存在于 Windows 7 和 Windows Server 2008 R2 上。
It's a MS product, it's free, and it rocks!
这是一款 MS 产品,它是免费的,而且非常棒!
回答by Rajesh Gautam PhD
For inclusion/invocation from within a BATCH file use (say for removing Debug and Release folder):
要从 BATCH 文件中包含/调用(例如删除 Debug 和 Release 文件夹):
for /d /r . %%d in (Debug Release) do @if exist "%%d" echo "%%d" && rd /s/q "%%d"
double %
are required within a batch file to work as escape chars. Else it reports error of syntax.
double%
在批处理文件中需要用作转义字符。否则它会报告语法错误。
Thanks.
谢谢。
回答by BlackTigerX
for /f "usebackq" %d in (`"dir _svn /ad/b/s"`) do rd /s/q "%d"
http://ebersys.blogspot.com/2008/07/recursively-delete-svn-folders-easy-way.html
http://ebersys.blogspot.com/2008/07/recursively-delete-svn-folders-easy-way.html
回答by Grant
In Windows? If you are using tortoiseSVN you can use the export command to export a copy of the project without the .svn/_svn folders.
在 Windows 中?如果你使用的是 tortoiseSVN,你可以使用 export 命令导出一个没有 .svn/_svn 文件夹的项目副本。
回答by Zhu Tao
import os
import shutil
curdir = os.path.abspath(os.path.dirname(__file__))
def removedir(dirname, name = ".svn"):
if os.path.isdir(dirname):
for file in os.listdir(dirname):
if os.path.isdir(os.path.join(dirname, file)) and file == name:
thedir = os.path.join(dirname, name)
shutil.rmtree(thedir)
print ".",
else:
removedir(os.path.join(dirname, file))
I think you can try this Python script, which will work under any OS if you've got Python installed.
我想你可以试试这个 Python 脚本,如果你安装了 Python,它可以在任何操作系统下运行。
回答by Teorist
回答by Teorist
Here... with FreeCommander or TotalCommander
在这里...使用 FreeCommander 或 TotalCommander
http://www.broobles.com/blog/posts/36
http://www.broobles.com/blog/posts/36
socendani
索森达尼