如何重命名这样的文件?
Cf.EL#131.csv.[daily_report+cf.com]
其中 .com] 是扩展名。
当我尝试这个时:
$file='Cf.EL#131.csv.[daily_report+cf.com]'
Rename-Item $file pippo.txt
最佳答案
Rename-Item
cmdlet 没有 LiteralPath
参数,这是您在本例中需要的参数,因为文件路径中包含方括号,用于根据 POSIX 标准的字符类。因此,作为解决方法,请使用 Move-Item
:
Move-Item -LiteralPath $file -Destination pippo.txt
关于Powershell 使用通配符重命名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16173927/