私はpowershellを初めて使いました。この質問はその点を証明します。私は、このファイルを解析するコマンドを実行しようとしているforeachを使った簡単なpowershellコマンドのコピーで助けが必要
fnameA.ext;fnameB.ext;fnameC.ext;....
...私は次のようにセミコロンで区切られたファイル名を含むtxtファイルを持って、コマンドラインから単純な作業をしようとしている、内容を分割セミコロンで入力し、各ファイルのコピーコマンドを目的のディレクトリに実行します。ここで
は、私が実行しているコマンドです:
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
ワンライナーの回避に完全に同意します。 _常に、簡潔性よりも読みやすさが優先されます。 –