[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

Copy Files

Hi guys,

Can you help me to create a power shell script in order to copy from a network path 2 files with specific name to another network destination and in the destination always overwrite the existing files.
Also how i can execute after this batch file.

Regards
0
DareDevilE12
Asked:
DareDevilE12
  • 3
  • 2
  • 2
2 Solutions
 
n2fcCommented:
Not quite sure what you are asking "execute after this batch file"

Script is just 2 copy commands:

copy [\\server\path\file1]  [\path\]
copy [\\server\path\file2]  [\path\]

Open in new window


The default in powershell is to copy with replace (overwrite).


FYI:  Powershell Quick Reference:
http://www.microsoft.com/en-us/download/details.aspx?id=7097
0
 
AkulshCommented:
Robocopy tool of Microsoft will do the job much better, and keep logs as well. Put Net Use and Robocopy commands in a batch (*.bat) file.

In other words, use of Powershell is not the best solution in this case.
0
 
DareDevilE12Author Commented:
Can you please Akulsh write an example of robocopy syntax, and how i can also use this log ability.

Regards
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AkulshCommented:
Something like this:

net use J: \\Server1\Share1
net use K: \\Server2\Share2

C:
cd\
Robocopy J:\ K:\ file1.ext /Log:C:\Temp\Robocopy1.log
Robocopy J:\ K:\ file2.ext /Log:C:\Temp\Robocopy2.log

net use J: /delete /y
net use K: /delete /y


By default, Robocopy will overwrite a file.
0
 
AkulshCommented:
Even simpler (this will append to the log while copying 2nd file):

Robocopy \\Server1\Share1\ \\Server2\Share2\ file1.ext /Log:C:\Temp\Robocopy.log
Robocopy \\Server1\Share1\ \\Server2\Share2\ file2.ext /Log+:C:\Temp\Robocopy.log
0
 
DareDevilE12Author Commented:
Thanks for your help guys

Regards
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now