我是 powershell 新手,这个问题将证明这一点。我正在从命令行尝试一个简单的任务,其中我有一个 txt 文件,其中包含用分号分隔的文件名,例如...
fnameA.ext;fnameB.ext;fnameC.ext;....
我正在尝试运行一个命令来解析这个文件,用分号分割内容,然后为每个文件运行一个复制命令到所需的目录。
这是我正在运行的命令:
gc myfile.txt |% {$_.split(";") | copy $_ "C:\my\desired\directory"}
但是对于列表中的每个项目,我都会收到这样的错误...
Copy-Item : The input object cannot be bound to any parameters for the command either because the command does not take
pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:36
+ gc bla.txt |% {$_.split(";") | copy <<<< $_ "C:\my\desired\directory"}
+ CategoryInfo : InvalidArgument: (fileA.txt:String) [Copy-Item], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.CopyItemCommand