【发布时间】:2022-04-05 05:10:29
【问题描述】:
我正在使用New-Item cmdlet 创建一个新文件夹,但意外地发现它没有可用的-Literalpath 参数。我的路径中包含方括号。我该怎么做才能解决这个问题?
【问题讨论】:
-
> New-Item "this is [some] path" -ItemType "directory"这似乎对我有用。它也适用于完整路径。难道是你在不带括号的情况下尝试这个?括号不在Forbidden characters and names -
项目名称中可以有方括号....:
New-Item -Path "/the/path/to/your[file]here.txt" -ItemType Directory -
@Bakudan @Stuart 是的,我可以在新创建的文件/目录的名称中使用方括号,但不能使用
-Path。说这个代码New-Item -Path "G:\1\jj[jj]j" -Name "121" -ItemType Directory -
@preachers
New-Item -Path "G:\1\jj[jj]j\jj[dqiw]j" -Type Directory。问题解决了。 -
@Ansgar Wiechers 谢谢。我早该想到的!这很容易。
标签: powershell windows-10 powershell-v5.1