简体   繁体   English

Powershell-如何将文件列表复制到目标

[英]Powershell - How copy list of files to destination

I have a textfile (myfile.txt) that contains the source/destination of files to copy. 我有一个文本文件(myfile.txt),其中包含要复制的文件的源/目标。 For example.... 例如....

c:\work\test1.txt \\server.usa.svr.com\sites\mysite\ztest1.txt
c:\work\test2.txt \\server.usa.svr.com\sites\mysite\ztest2.txt
c:\work\test3.txt \\server.usa.svr.com\sites\mysite\ztest3.txt
c:\work\test4.txt \\server.usa.svr.com\sites\mysite\ztest4.txt
c:\work\test5.txt \\server.usa.svr.com\sites\mysite\ztest5.txt
c:\work\test6.txt \\server.usa.svr.com\sites\mysite\ztest6.txt

Using powershell how can I open the file and copy from source to destination, for each file. 如何使用powershell打开文件并针对每个文件从源复制到目标。 Also, giving a status if error or success? 另外,如果错误或成功,则给出状态?

Thanks! 谢谢!

If you don't have spaces in file names (or they are properly quoted) you can try the following: 如果文件名中没有空格(或使用正确的引号),则可以尝试以下操作:

Import-Csv myfile.txt -Delimiter ' ' -Header Path,Destination | Copy-Item

You can pipe to Copy-Item -WhatIf first to see whether it's doing the right thing. 您可以先通过管道传递给Copy-Item -WhatIf以查看它是否做对了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用列表将多个子目录中的源文件匹配,然后使用Powershell复制到目标 - How to match source files in multiple subdirectories with a list and then copy to destination using powershell Powershell 将文件复制到新目标的脚本 - Powershell Script to Copy Files to new Destination Powershell 列出 Excel 文件并复制 - Powershell List Excel Files and Copy Powershell - 将目录和文件从源文件夹复制到目标文件夹 - Powershell - Copy directory and files from source folder to destination folder Powershell将某些特定文件和某些子文件夹复制到目标位置 - Powershell to copy some specific files and some subfolders to destination 如何复制文件列表并在PowerShell循环中重命名它们 - How do I copy a list of files and rename them in a PowerShell Loop PowerShell将文件复制到目标的子文件夹,同时排除目标中的某些文件夹 - PowerShell to copy files to destination's subfolders while excluding certain folders in the destination Powershell 将文件夹和内容复制到目标 - Powershell copy folder and content to destination 如何在 powershell 脚本中使用凭据将文件复制到目标服务器? - How to use credentials in powershell script to copy file to a destination server? Powershell:如何将文件从TFS复制到其他目标 - Powershell: How to copy a file from TFS to a different destination
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM