所以我试图将 44k 文件从一台服务器复制到另一台服务器。
我的 Powershell 脚本是:
Import-CSV f:\script\Listoffiles.csv | foreach $line {Move-item $_.Source $_.Destination}
Run Code Online (Sandbox Code Playgroud)
使用 CSV 格式:
Source, Destination
E:\folder1\folder2\file with space.txt, \\1.2.3.4\folder1\folder2\file with space.txt
Run Code Online (Sandbox Code Playgroud)
我不断得到:
A positional parameter cannot be found that accepts argument '\\1.2.3.4\folder1\folder2\file'.
At line:1 char:10
+ move-item <<<< E:\folder1\folder2\file with space.txt \\1.2.3.4\folder1\folder2\file with space.txt
+ CategoryInfo : InvalidArgument: (:) [Move-Item], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.MoveItemCommand
Run Code Online (Sandbox Code Playgroud)
所以我尝试将 "s 和 's 放在两个路径周围,但我仍然遇到任何一个Move-Item: Could not find a part of the path错误。
谁能帮我?
您是否尝试过在 Move-Item 参数周围放置引号而不是 csv 项目?另外,删除 $line 变量。
Import-CSV f:\script\Listoffiles.csv | foreach {Move-item "$_.Source" "$_.Destination"}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5290 次 |
| 最近记录: |