递归删除匹配文件和目录的命令行 [英] Command line to delete matching files and directories recursively

查看:28
本文介绍了递归删除匹配文件和目录的命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何递归删除所有文件&匹配特定模式的目录?例如删除所有.svn"目录及其包含的文件?

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)

(Sadly DOS only)

推荐答案

既然你在找 DOS 解决方案,上周的帖子几乎一模一样,共识是:

Since you're looking for a DOS solution, last week's post was almost identical and the consensus was:

在Windows中递归删除指定名称文件夹的命令行工具?

对于/d/r .%d in (.svn) do @if 存在"%d" rd/s/q "%d"

for /d /r . %d in (.svn) do @if exist "%d" rd /s/q "%d"

for/f "usebackq" %d in ("dir .svn/ad/b/s") 做 rd/s/q "%d"

for /f "usebackq" %d in ("dir .svn /ad/b/s") do rd /s/q "%d"

实际上,SVN 还为您提供了导出工作目录而不带 .svn/_svn 目录的选项.

Actually, SVN also gives you the option to export a working directory without the .svn/_svn directories.

事后的想法,三年后:我认为人们最终需要递归删除 .svn/_svn 文件夹的原因是因为他们直接将本地工作副本复制到新位置,以便将修改后的版本与干净的导出进行文件夹比较,即在修改后的本地工作副本出现问题后.(至少这就是我需要它的原因.在可能的情况下使用svn export"肯定更容易/更快.)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆