[英]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.