Link to home
Start Free TrialLog in
Avatar of Siddharth S
Siddharth S

asked on

Copy from network drive to local computer using batch

Hello experts,

Is there a batch file I can create which can copy all files from \\192.168.0.2\Script\sw to C:\CSV\sw
I also need the same batch file to copy from \\192.168.0.2\Script\hw to C:\CSV\hw

Is that possible?
Avatar of oBdA
oBdA

@echo off
setlocal
for %%a in (sw hw) do (
	robocopy.exe "\\192.168.0.2\Script\%%a" "C:\CSV\%%a" /e /r:0 /w:0
)

Open in new window

Avatar of Siddharth S

ASKER

Wow, that was fast and works! Thanks but I have another thing. I have to copy from different locations onto one folder, can I incorporate it all in one.

Say I have to copy from  \\192.168.0.99\Script\sw to  C:\CSV\sw and \\192.168.0.99\Script\hw to C:\CSV\hw
SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Bill, duplicate handling wont be a problem. If two files with the same name exists, then I want them to overwrite.
Let me try this and get back to you.
You might want to add the /xo (eXclude Older) switch to the robocopy command then, to make sure only the latest file is copied.
Thanks guys, solved it. Great help as usual.