Windows批处理文件删除的.svn文件和文件夹 [英] Windows batch file to delete .svn files and folders

查看:312
本文介绍了Windows批处理文件删除的.svn文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了删除MyFolder中我用在批处理文件中这个简单的线条都的.svn文件/文件夹/子文件夹:

In order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file:

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X")

这工作,但如果没有的.svn文件/文件夹的批处理文件显示警告说:该系统找不到指定的文件
此警告是非常嘈杂,所以我不知道如何为使其明白,如果它没有找到任何的.svn文件/文件夹,他必须跳过RD命令。

This works, but if there are no ".svn" files/folders the batch file shows a warning saying: "The system cannot find the file specified." This warning is very noisy so I was wondering how to make it understand that if it doesn't find any ".svn" files/folders he must skip the RD command.

通常使用通配符就够了,但在这种情况下,我不知道如何使用它们,因为我不希望删除文件/文件夹与.svn文件扩展名,但我想删除名为正是.svn这样的文件/文件夹,所以如果我这样做:

Usually using wild cards would suffice, but in this case I don't know how to use them, because I don't want to delete files/folders with .svn extension, but I want to delete the files/folders named exactly ".svn", so if I do this:

FOR /R myfolder %%X IN (*.svn) DO (RD /S /Q "%%X")

它不会删除文件/恰好名为.svn文件了的文件夹。
我想也是这个:

it would NOT delete files/folders named exactly ".svn" anymore. I tried also this:

FOR /R myfolder %%X IN (.sv*) DO (RD /S /Q "%%X")

但它也不起作用,他没有删除

but it doesn't work either, he deletes nothing.

推荐答案

您可以尝试

FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)

这篇关于Windows批处理文件删除的.svn文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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