【发布时间】:2016-09-12 17:30:14
【问题描述】:
我们有用户发送的加密的 .txt 文件。我们解密它们并将其作为输入发送到下游的第 3 方系统。它一直运行良好,但用户开始发送文件是 .TXT 而不是 .txt。它在解密期间没有任何区别,但它会影响下游系统。我们应该将 .TXT 更改为 .txt
我试过这样改
Copy-Item -Path $myOfile –Destination ([io.path]::ChangeExtension($myOfile, '.txt')) -Verbose
这里的 $myOfile 是我的文件名,它的名字是这样的
20160506_205400_Sender_header.TXT.GPG 解密后变为20160506_205400_Sender_header.TXT
我使用上面的命令将其更改为20160506_205400_Sender_header.txt,它会引发以下错误
Copy-Item : Cannot overwrite the item C:\Sender\Submit\20160506_205400_Sender_header.TXT with itself.
.TXT 和 .txt 之间似乎没有区别。有没有办法或解决方法?
【问题讨论】:
-
您可以将扩展名更改为其他内容 (tmp),然后再改回 txt。 *编辑:这对我有用:
dir *.txt | % {ren $_.fullname ($_.name.substring(0, $_.name.length - 3) + 'txt')}
标签: windows powershell file-extension renaming