I'm having difficulty returning JUST folders (ignore files) using a windows batch file.
Here's what I have right now. Currently it's returing files and sub-sub-folders.
for /r %%g in ("xx*") do echo %%g
Also, say I want to only return the folders that start with a couple different prefixes.
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?
Thanks.
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
)
This will find all of the subfolders that start with w*
这是安德鲁答案的修改版本,可以处理多个前缀:
dir /a:d /b w* we* cm* cr*
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.