powershell - 如果从文本列表移动文件/文件夹,则会出现位置错误

powershell - 如果从文本列表移动文件/文件夹,则会出现位置错误

我尝试从文本列表移动我的文件夹和文件,但出现此错误,我使用的是 Windows Server 2012

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> Get-Content x:\TNT Village - psp, psx - 2 parte\ps2\downloads\filestocopy.txt | ForEach-Objec
t {move-item $_ X:\TNT Village - psp, psx - 2 parte\ps2\downloads\--completati}
Get-Content : A positional parameter cannot be found that accepts argument 'Village'.
At line:1 char:1
+ Get-Content x:\TNT Village - psp, psx - 2 parte\ps2\downloads\filestocopy.txt |  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Content], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand

PS C:\Users\Administrator>

村庄是道路的一部分..为什么它会给我位置错误?

在 filestocopy.txt 文件中我有以下内容:

X:\TNT Village - psp, psx - 2 parte\ps2\downloads\hitman 2
X:\TNT Village - psp, psx - 2 parte\ps2\downloads\Jak 3.rar
X:\TNT Village - psp, psx - 2 parte\ps2\downloads\James Cameron's Dark Angel PAL PS2DVD
X:\TNT Village - psp, psx - 2 parte\ps2\downloads\Kh_1.iso
X:\TNT Village - psp, psx - 2 parte\ps2\downloads\Marvel La Grande Alleanza.rar

答案1

如果路径或文件名包含空格或可将命令行解释为命令的字符,请使用'或符号。"

例子:Get-Content "x:\TNT Village - psp, psx - 2 parte\ps2\downloads\filestocopy.txt" | ForEach-Object {move-item $_ "X:\TNT Village - psp, psx - 2 parte\ps2\downloads\--completati"}

相关内容