Powershell如何使用仅知道一部分文件名的测试路径

rsc*_*rin 4 powershell powershell-2.0

我可以使用经典的Test-Path来检查在特定文件夹中是否存在名称中带有特定单词的文件?

例如,我想检查是否存在以单词“ LAB”开头的文件。这个词后面有我无法计算的日期戳。

CB.*_*CB. 5

为什么不:

test-path c:\myfolder\lab* -pathtype leaf #leaf is for file (get-help test-path -full)
Run Code Online (Sandbox Code Playgroud)