我正在尝试从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
我知道这很简单,但我真的很感激一些帮助.
powershell ×1