在Windows中查找空目录

在Windows中查找空目录,windows,Windows,如何在Windows中查找所有空目录?对于Unix,存在一个。所以有一个现成的解决方案。使用windows的最佳解决方案是什么?到目前为止,我找到了几种解决方案: 使用 安装Cygwin或,然后按照 使用Python或其他脚本语言,例如Perl 下面的Powershell代码段将搜索C:\whatever并返回空的子目录 $a = Get-ChildItem C:\whatever -recurse | Where-Object {$_.PSIsContainer -eq $True} $a |

如何在Windows中查找所有空目录?对于Unix,存在一个。所以有一个现成的解决方案。使用windows的最佳解决方案是什么?

到目前为止,我找到了几种解决方案:

  • 使用
  • 安装Cygwin或,然后按照
  • 使用Python或其他脚本语言,例如Perl
  • 下面的Powershell代码段将搜索C:\whatever并返回空的子目录

    $a = Get-ChildItem C:\whatever -recurse | Where-Object {$_.PSIsContainer -eq $True}
    $a | Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName
    
    import os;
    folder = r"C:\whatever";
    
    for path, dirs, files in os.walk(folder):
        if (dirs == files): print path
    
    下面的python代码将列出所有空的子目录

    $a = Get-ChildItem C:\whatever -recurse | Where-Object {$_.PSIsContainer -eq $True}
    $a | Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName
    
    import os;
    folder = r"C:\whatever";
    
    for path, dirs, files in os.walk(folder):
        if (dirs == files): print path
    

    我想说,OP应该使用Powershell方法。如果有基于Windows的解决方案,您是否想象使用Unix抽象层/仿真器是的,我同时使用windows和unix,因此更喜欢同时使用这两种系统的解决方案。实际上,在出现这个问题的情况下,我更喜欢python解决方案。为了完整性,我刚刚添加了powershell。我会解决的。我不知道这是你自己的答案…:P哦,由你决定。