gpt4 book ai didi

powershell - 使用 powershell 将双引号写入文件名文本

转载 作者:行者123 更新时间:2023-12-03 00:43:57 26 4
gpt4 key购买 nike

在为文件名文本添加双引号时,我煞费苦心地想看看哪里出了问题。以下代码在 -whatif 保护伞下运行良好,但并非没有。

$a = "20`" board"
get-childitem | rename-item -newname {$_.fullname -replace "20 board", $a } -whatif

get-childitem | rename-item -newname {$_.fullname -replace "20 board","20`" board" } -whatif

期望的结果是将 20 板 替换为 20"板。上面的代码片段给我一个 rename-item : Illegal characters in path. 错误。

最佳答案

在 Windows 中,您不能在文件或文件夹名称中使用某些字符;双引号就是其中之一。

阅读更多信息 https://learn.microsoft.com/en-us/windows/desktop/fileio/naming-a-file .

该页面的摘录:

The following reserved characters [are not allowed]:

< (less than)
(greater than)

: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)

关于powershell - 使用 powershell 将双引号写入文件名文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52618346/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com