![power shell 列出带有 (1) 或 (2) 或 (3) 的文件](https://linux22.com/image/1583144/power%20shell%20%E5%88%97%E5%87%BA%E5%B8%A6%E6%9C%89%20(1)%20%E6%88%96%20(2)%20%E6%88%96%20(3)%20%E7%9A%84%E6%96%87%E4%BB%B6.png)
我想使用 PowerShell 列出所有文件名末尾带有 (1) 或 (2) 或 (3) 的文件。我更喜欢使用筛选选项
我尝试使用此命令
Get-ChildItem -Path 'E:\' -Filter "*(*)" -Recurse -Directory).Fullname
问题是它将获取所有带有括号内数字的文件,而不是 (1) 或 (2) 或 (3)
有人能帮我给我正确的命令吗
答案1
PowerShell 允许通配符和范围在文件/路径名中。
如果你在之后files
不要忘记扩展
Get-ChildItem -Path $ENV:USERPROFILE -Include '*([1-3]).*' -Recurse
此处的示例运行返回:
Directory: C:\Users\LotPings\OneDrive\Pictures\Screenshots
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---l 2017-07-23 19:29 (52696) 2017-07-23 (3).png
-a---l 2018-06-16 13:59 (50499) 2018-06-16 (1).png