批量删除一个目录下所有同名子目录的一种方法

1. 查询该目录下所有该名称的目录的路径

使用Log Parser 2.2工具查询指定目录下所有指定名称的目录的路径,执行的sql语句如下:

"select path into svn.csv from E:\LJMIS\*.* where Attributes like 'D%' and name='.svn'" -i:fs -o:csv

dos下删除目录树的命令如下:

rd /s /q

综合使用,在查询的时候,自动合成删除命令,执行如下:

C:\Program Files\Log Parser 2.2>logparser "select 'rd /s /q ',path into e:\svn.csv from E:\LJMIS\*.* where Attributes like 'D%' and name='.svn'" -i:fs -o:csv

结果以.csv格式删除,保存在e:\svn.csv文件中。结果大致如下:

rd /s /q E:\LJMIS\打印模块\.svn

rd /s /q E:\LJMIS\Raize Components v3.0\.svn

rd /s /q E:\LJMIS\SMExport_v4.68\.svn

…… ……

2. 执行删除语句

复制生成的删除命令,在cmd中执行,就ok了。不过有一个小bug,“rd /s /q”命令对于路径中包含空白字符的目录名的子目录删除,总是报找不到路径的错误,可以适当在含空白字符的目录名上加上“”,就可以了。

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>