0

I have a textfile (myfile.txt) that contains the source/destination of files to copy. 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. Also, giving a status if error or success?

Thanks!

2
  • Could you tell what have you tried so far? Commented Feb 19, 2014 at 9:43
  • Why not quick and dirty? Replace c:\ with cp c:\, save as .ps1 and run the script. Commented Feb 19, 2014 at 9:49

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.