尝试复制文本文件中包含的一组文件

Ala*_*Dad 3 powershell

我正在尝试从txt文件复制文件列表,作为新手,我很难过.

这是一些文本文件.真正的文件没有额外的行,但我必须这样做:

"D:\Shared\Customer Care\Customer Care Common\Customers Contracted\Customers Contracted\Fred 44705"
"D:\Shared\Customer Care\Customer Care Common\Customers Contracted\Customers Contracted\Johnson 47227"
"D:\Shared\Customer Care\Customer Care Common\Customers Contracted\Customers Contracted\Daniel 35434"
"D:\Shared\Customer Care\Customer Care Common\Customers Contracted\Customers Contracted\Frank, John 48273"
Run Code Online (Sandbox Code Playgroud)

我也尝试用双引号括起文件名字符串.

这是我正在尝试使用的简单脚本:

Get-Content c:\users\scripts\files-to-fix.txt | Foreach-Object {copy-item $_ d:\junk}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

复制项目:找不到驱动器.名称为"D"的驱动器不存在.在C:\ users\mhyman\scripts\copyfiles.ps1:2 char:81 + Get-Content c:\ users\mhyman\scripts\files-to-fix.txt | Foreach-Object {copy-item <<<< $ _ d:\ junk} + CategoryInfo:ObjectNotFound:('D:String)[Copy-Item],DriveNotFoundException + FullyQualifiedErrorId:DriveNotFound,Microsoft.PowerShell.Commands.CopyItemCommand


我知道这很简单,但我真的很感激一些帮助.

man*_*lds 6

我认为这是导致问题的周围引号(如错误所示,"D未找到名称驱动器.请尝试此操作:

get-content c:\users\scripts\files-to-fix.txt | %{ copy-item $_.trim('"') d:\junk}
Run Code Online (Sandbox Code Playgroud)

当然,如果您可以控制txt文件,请输入不带引号的列表.