2010-06-09 17:13:59 +0000 2010-06-09 17:13:59 +0000

答案 (4)

得分 109
2013-01-24 21:16:24 +0000

在Powershell 3.0中,更简单,

gci -Directory #List only directories
gci -File #List only files

这个更短,

gci -ad # alias for -Directory
gci -af # alias for -File
```。
Advertisement

解决方案找到了!

得分 78
2010-06-09 18:06:03 +0000

试试这个。

gci . *.* -rec | where { ! $_.PSIsContainer }
Advertisement
得分 3
2014-05-19 17:52:55 +0000
Advertisement

在PowerShell 3.0中,你还可以使用新增加的 -Attributes参数 (与逻辑运算符一起使用)

Get-ChildItem -Recurse -Attributes !Directory+!System

Golfed

dir -r -Attributes !D
```。
得分 -5
2015-05-07 11:27:01 +0000

在powershell 2.0中,我想到的最好最简单的解决方案是包含所有扩展名为:

get-childitem -Recurse -include *.*

文件夹没有扩展名,所以它们被排除在外,小心没有扩展名的文件。