命令行以递归方式删除匹配的文件和目录 [英] Command line to delete matching files and directories recursively
问题描述
如何递归删除所有档案&匹配某个模式的目录?例如
How can I recursively delete all files & directories that match a certain pattern? e.g. remove all the ".svn" directories and the files they contain?
(仅限于DOS)
推荐答案
因为你正在寻找DOS解决方案,上周的帖子几乎是一样的,一致的是:
Since you're looking for a DOS solution, last week's post was almost identical and the consensus was:
代表/ d / r。 %d在(.svn)do @if存在
%drd / s / q%d
for /d /r . %d in (.svn) do @if exist "%d" rd /s/q "%d"
或
代表/ fusebackq%d in(dir .svn
/ ad / b / s) do rd / s / q%d
for /f "usebackq" %d in ("dir .svn /ad/b/s") do rd /s/q "%d"
实际上,SVN还提供导出工作目录的选项, / _svn目录。
Actually, SVN also gives you the option to export a working directory without the .svn/_svn directories.
后来,三年后:
我认为人们最终需要递归删除.svn / _svn文件夹的原因是因为他们' ve直接复制他们的本地工作副本到一个新的位置,以便做一个文件夹比较他们的修改版本相比,一个干净的出口,即一些东西变得与修改后的本地工作副本。 (至少这就是为什么我需要它。它是绝对更容易/更快地只使用'svn导出',当可能的时候。)
Afterthoughts, three years later: I think the reason people end up needing to recursively delete the .svn/_svn folders is because they've directly copied their local working copy to a new location in order to do a folder comparison of their modified version compared to a clean export, i.e. after something goes awry with the modified local working copy. (At least that's why I've needed it. It's definitely easier/faster to just use 'svn export' when that's possible.)
这篇关于命令行以递归方式删除匹配的文件和目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!