Get-ChildItem中的多个过滤器

问题描述 投票:1回答:1

我想在PowerShell脚本中应用多个qazxsw poi,现在我只能添加单个qazxsw poi,如下所示

filter

从上面的查询我能够只从filter复制一个文件Get-Childitem "D:\SourceFolder" -recurse -filter "*kps.jpg" | Copy-Item -Destination "D:\DestFolder" kps.jpg,我怎么能给mupliple名称复制多个文件?

powershell powershell-v3.0 copy-paste
1个回答
5
投票

要过滤多个条件,请使用SourceFolder参数而不是DestFolder

Include


Note: The -Filter only works if you also specify Get-Childitem "D:\SourceFolder" -Recurse -Include "*kps.jpg", "*kps.png", "*kps.bmp" | Copy-Item -Destination "D:\DestFolder" or have the path end in Include like in -Recurse


Note2: As \* commented, Get-Childitem "D:\SourceFolder\*" would work faster that Lee_Daily (or -Filter) parameters. Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects. Otherwise, PowerShell filters the objects after they are retrieved. See -Include

-Exclude的缺点是你只能提供一个单一的文件名过滤器,而the docs允许一组通配符过滤器。

© www.soinside.com 2019 - 2024. All rights reserved.