2

我正在尝试查找多个文件夹中的所有文件,但唯一的问题是文件存在于某些文件夹中

E:\sample\cd.dll
E:\sample1\sample\cd.dll

如果我使用

Get-ChildItem -recurse

它返回 cd.dll 的两个 FileSystemInfo。结果应该只有一个 cd.dll 的 FileName 提前谢谢。

4

1 回答 1

2
Get-ChiltItem -recurse | Select-Object -Unique

Note that -Unique is case-sensitive so you may want to use the Sort-Object cmdlet:

Get-ChiltItem -recurse | Sort-Object -Unique

You can also eliminates duplicates with the Get-Unique cmdlet but it requires the objects to be sorted first for the cmdlet to work properly

于 2013-05-15T09:25:09.527 回答