windows-7 – 列出具有指定名称的所有子目录
发布时间:2020-12-13 22:32:39 所属栏目:Windows 来源:网络整理
导读:我试图获得所有子目录(递归)的路径列表,这些路径具有一些指定的名称,例如“斌”.问题是如果当前目录包含该名称的子目录,则DIR命令将仅在该子目录中执行,忽略其他子目录. 例: C:DEVELOPMENTRESEARCHverMicrosoft Windows [Version 6.1.7601]C:DEVELOPMENT
我试图获得所有子目录(递归)的路径列表,这些路径具有一些指定的名称,例如“斌”.问题是如果当前目录包含该名称的子目录,则DIR命令将仅在该子目录中执行,忽略其他子目录.
例: C:DEVELOPMENTRESEARCH>ver Microsoft Windows [Version 6.1.7601] C:DEVELOPMENTRESEARCH>dir *bin* /ad /s /b C:DEVELOPMENTRESEARCHbin C:DEVELOPMENTRESEARCHApache2bin C:DEVELOPMENTRESEARCHApachebin C:DEVELOPMENTRESEARCHApachebin1 C:DEVELOPMENTRESEARCHC#ConsoleAppsMiscTestsbin C:DEVELOPMENTRESEARCH>dir bin* /ad /s /b C:DEVELOPMENTRESEARCHbin C:DEVELOPMENTRESEARCHApachebin C:DEVELOPMENTRESEARCHApachebin1 C:DEVELOPMENTRESEARCHC#ConsoleAppsMiscTestsbin C:DEVELOPMENTRESEARCH>dir bin /ad /s /b C:DEVELOPMENTRESEARCHbintest C:DEVELOPMENTRESEARCH>rmdir bin /s /q C:DEVELOPMENTRESEARCH>dir bin /ad /s /b C:DEVELOPMENTRESEARCHApachebin C:DEVELOPMENTRESEARCHC#ConsoleAppsMiscTestsbin C:DEVELOPMENTRESEARCH> dir * bin * / ad / s / b输出名称中包含bin的所有子目录.这个输出没问题.与dir bin * / ad / s / b相同,它输出名称以bin开头的所有子目录.但是dir bin / ad / s / b仅输出当前目录中具有名称bin的第一个子节点的内容.期望的输出是: C:DEVELOPMENTRESEARCHbin C:DEVELOPMENTRESEARCHApachebin C:DEVELOPMENTRESEARCHC#ConsoleAppsMiscTestsbin 我怎样才能做到这一点? 注意:如果当前目录不包含bin子,则输出是预期的. (我删除了bin子来显示这个) 解决方法
如果当前目录包含bin子目录,则使用标准DOS命令很困难.我认为你有三个基本选择:
# Option 1: FOR and check directory existance (modified from MBu's answer - the # original answer just appended 'bin' to all directories whether it existed or not) # (replace the 'echo %A' with your desired action) for /r /d %A in (bin) do if exist %ANUL echo %A # Option 2: PowerShell (second item is if you need to verify it is a directory) Get-ChildItem -filter bin -recurse Get-ChildItem -filter bin -recurse |? { $_.Attributes -match 'Directory' } # Option 3: Use UNIX/Cygwin find.exe (not to be confused in DOS find) # (you can locate on the net,such as GNU Utilities for Win32) find.exe . -name bin find.exe . -name bin -type d > DOS Testing if drive or directory exists (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 在Windows上使用音频检测进程
- .net – 我应该在IIS中托管我的WCF服务吗?
- scheduled-task – 错误0xE0434F4D为Windows计划任务的“上
- .net – 我们可以将’Microsoft.ACE.Oledb.12.0.dll’的引用
- windows – 符合MSSCCI标准的git客户端
- reactjs – jest没有实现window.alert()
- Windows后登陆没有图形界面只有cmd,explorer.exe不能启动
- 从Windows窗体加载WPF窗口时出现问题System.ExecutionEngin
- win10 装centos7 虚拟机
- 命令行界面 – Microsoft设置命令行快捷方式的详尽列表是什
推荐文章
站长推荐
热点阅读