【问题标题】:Powershell rename a file with wildcard charactersPowershell用通配符重命名文件
【发布时间】:2013-04-16 22:30:36
【问题描述】:

如何重命名这样的文件?

Cf.EL#131.csv.[daily_report+cf.com]

.com] 是扩展名。

当我尝试这个时:

 $file='Cf.EL#131.csv.[daily_report+cf.com]'
 Rename-Item $file pippo.txt

【问题讨论】:

  • 你想用哪个部分作为通配符?

标签: powershell rename


【解决方案1】:

Rename-Item cmdlet 没有 LiteralPath 参数,这是您在这种情况下所需要的,因为文件路径中有方括号,用于根据 POSIX 标准的字符类。因此,作为一种解决方法,请使用Move-Item:

Move-Item -LiteralPath $file -Destination pippo.txt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    • 2014-12-09
    • 2015-11-26
    • 1970-01-01
    相关资源
    最近更新 更多