Windows批处理文件 - 显示所有子文件夹 [英] Windows batch file - display all sub-folders

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

问题描述

我有困难,只返回文件夹(忽略文件)使用Windows批处理文件。

I'm having difficulty returning JUST folders (ignore files) using a windows batch file.

这就是我现在所拥有的。目前,它的returing文件和子子文件夹。

Here's what I have right now. Currently it's returing files and sub-sub-folders.

for /r %%g in ("xx*") do echo %%g

此外,再说我也想只返回一对夫妇不同的prefixes启动文件夹。

Also, say I want to only return the folders that start with a couple different prefixes.

例如:我想呼应只以w *,我们*,*厘米,CR *等在文件夹工作范围内启动下的文件夹中。我做的是可以使用一个批处理文件?

For example: I want to echo only the folders that start with w*, we*, cm*, cr*, etc under within in the folder "work". I do Is this possible using a batch file?

感谢。

推荐答案

您可以使用 DIR 命令修改 / A:D 这将告诉它只能搜索目录

You can use the dir command with the modifier /a:d which will tell it to only search directories

FOR /f "tokens=*" %%i in ('DIR /a:d /b w*') DO (
    ECHO %%i
)

这会发现所有以 W *

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

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