如何列出使用Windows批处理文件中的所有空目录? [英] How to list all the empty directories using windows batch file?

查看:162
本文介绍了如何列出使用Windows批处理文件中的所有空目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Windows批处理文件,该文件列出了用户指定的根目录下的所有空的子目录present。

可以就同一人帮助?


解决方案

 关闭@echo
针对/ D / R%1 %% A有()做(
  DIR / A / B%%〜FA2 - ; NUL | FINDSTR^> NUL ||回声%%〜为fA

上述解决方案忽略隐藏的文件夹。我也被告知,同时使用/ D和FOR / R选项被窃听,虽然我从来没有遇到过的问题吧。


 关闭@echo
目录/ A / B%1 2 - ; NUL | FINDSTR^> NUL ||回声%%〜为fA
FOR / FEOL =:delims =%%的('DIR / S /广告/ B%1')做A(
  DIR / A / B%%〜FA2 - ; NUL | FINDSTR^> NUL ||回声%%〜为fA

这避免了/ D / R将包括隐藏文件夹的第二个解决方案。但我相信,如果文件夹名称中包含统一code那么它可能会失败。

I want to create a windows batch file which lists all the empty sub-directories present under the user specified root directory.

Can anybody help regarding the same?

解决方案

@echo off
for /d /r %1 %%A in (.) do (
  dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo %%~fA
)

The above solution ignores Hidden folders. I've also been told that using both /D and /R options with FOR is bugged, though I've never had a problem with it.


@echo off
dir /a /b %1 2>nul | findstr "^" >nul || echo %%~fA
for /f "eol=: delims=" %%A in ('dir /s /ad /b %1') do (
  dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo %%~fA
)

The 2nd solution that avoids FOR /D /R will include Hidden folders. But I believe it can fail if folder names contain Unicode.

这篇关于如何列出使用Windows批处理文件中的所有空目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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