我正在为cmd.exe
的
dir /s /b *foo*.docx
我想为此创建一个别名(或scriptlet?)。
我找到How do I do 'dir /s /b' in PowerShell?但是通过这种方法,我似乎无法传递参数*foo*.docx
。
答案 0 :(得分:3)
正如我在上面的评论中所述,您正在寻找:
gci -recurse -filter *foo*.docx | select -expandproperty fullname
gci
或Get-ChildItem
将返回与您指定的过滤器匹配的文件系统对象列表。每个对象都会随附一大堆信息,但由于您只对路径感兴趣,因此您可以通过管道传递fullname
属性select
,如图所示。 -expandproperty
标志将确保结果作为字符串数组而不是对象列表返回。
答案 1 :(得分:0)
Get-ChildItem -Recurse -Filter *foo*.docx | Select-Object FullName | Sort-Object Length