Windows – PowerShell复制项方法失败 – 文件名中的括号
发布时间:2021-01-28 02:13 所属栏目:52 来源:网络整理
导读:我试图使用Power Shell(v.1)仅复制匹配模式的文件.文件命名约定是: Daily_Reviews[0001-0871].journalDaily_Reviews[1002-9887].journal[...] 当我运行它时,方法“Copy-Item”抱怨: 无法检索cmdlet的动态参数.指定的通配符模式无效:Daily_Reviews [0001-0
我试图使用Power Shell(v.1)仅复制匹配模式的文件.文件命名约定是: Daily_Reviews[0001-0871].journal Daily_Reviews[1002-9887].journal [...] 当我运行它时,方法“Copy-Item”抱怨: 无法检索cmdlet的动态参数.指定的通配符模式无效:Daily_Reviews [0001-0871] .journal $source = "C:\Users\Tom\" $destination ="C:\Users\Tom\Processed\" if(-not(Test-Path $destination)){mkdir $destination | out-null} ForEach ($sourcefile In $(Get-ChildItem $source | Where-Object { $_.Name -match "Daily_Reviews\[\d\d\d\d-\d\d\d\d\].journal" })) { Copy-Item $sourcefile $destination } 解决方法好了,经过研究,我发现了一个解决方法:$src = [Management.Automation.WildcardPattern]::Escape($sourcefile) Copy-Item $src $destination (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读