Windows – PowerShell复制项方法失败 – 文件名中的括号
发布时间:2020-12-14 05:54:29 所属栏目:Windows 来源:网络整理
导读:我试图使用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:UsersTom" $destination ="C:UsersTomProcessed" if(-not(Test-Path $destination)){mkdir $destination | out-null} ForEach ($sourcefile In $(Get-ChildItem $source | Where-Object { $_.Name -match "Daily_Reviews[dddd-dddd].journal" })) { Copy-Item $sourcefile $destination } 解决方法
好了,经过研究,我发现了一个解决方法:
$src = [Management.Automation.WildcardPattern]::Escape($sourcefile) Copy-Item $src $destination (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 使用Windows Azure Service Bus进行邮件路由
- 带RemoteFX的Hyper-V服务器:我可以从服务器桌面RDP到其Win
- windows-server-2008-r2 – Windows Server 2008 R2最大打开
- windows-installer – 从VS安装项目升级时,版本和Bundle的U
- 记一个 中文乱码问题
- windows C++如何根据文本字符串计算其绘制需占用宽度
- winapi – 如何播放标准Windows声音?
- Windows 包管理工具 Scoop 安装部署
- windows – 检测批处理文件中是否打开了文件
- 使用.net以编程方式安装Windows Media Player