【发布时间】:2012-04-17 01:46:33
【问题描述】:
我正在尝试获取具有某些指定名称的所有子目录(递归)的路径列表,例如"bin"。问题是如果当前目录包含该名称的子目录,则 DIR 命令将仅在该子目录中执行,而忽略其他子目录。
例子:
C:\DEVELOPMENT\RESEARCH>ver
Microsoft Windows [Version 6.1.7601]
C:\DEVELOPMENT\RESEARCH>dir *bin* /ad /s /b
C:\DEVELOPMENT\RESEARCH\bin
C:\DEVELOPMENT\RESEARCH\Apache\2bin
C:\DEVELOPMENT\RESEARCH\Apache\bin
C:\DEVELOPMENT\RESEARCH\Apache\bin1
C:\DEVELOPMENT\RESEARCH\C#\ConsoleApps\MiscTests\bin
C:\DEVELOPMENT\RESEARCH>dir bin* /ad /s /b
C:\DEVELOPMENT\RESEARCH\bin
C:\DEVELOPMENT\RESEARCH\Apache\bin
C:\DEVELOPMENT\RESEARCH\Apache\bin1
C:\DEVELOPMENT\RESEARCH\C#\ConsoleApps\MiscTests\bin
C:\DEVELOPMENT\RESEARCH>dir bin /ad /s /b
C:\DEVELOPMENT\RESEARCH\bin\test
C:\DEVELOPMENT\RESEARCH>rmdir bin /s /q
C:\DEVELOPMENT\RESEARCH>dir bin /ad /s /b
C:\DEVELOPMENT\RESEARCH\Apache\bin
C:\DEVELOPMENT\RESEARCH\C#\ConsoleApps\MiscTests\bin
C:\DEVELOPMENT\RESEARCH>
dir *bin* /ad /s /b 输出名称中包含bin 的所有子目录。这个输出没问题。与dir bin* /ad /s /b 相同,它输出名称以bin 开头的所有子目录。但是dir bin /ad /s /b 只输出当前目录的第一个子目录的内容,名称为bin。期望的输出是:
C:\DEVELOPMENT\RESEARCH\bin
C:\DEVELOPMENT\RESEARCH\Apache\bin
C:\DEVELOPMENT\RESEARCH\C#\ConsoleApps\MiscTests\bin
我怎样才能做到这一点?
注意:如果当前目录不包含bin child,则输出如预期。 (我删除了binchild 来显示这个)
【问题讨论】:
标签: windows-7 batch-file command-prompt cmd