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?
Windows Batch

Avatar of undefined
Last Comment
Siddharth S

8/22/2022 - Mon
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

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
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Siddharth S

ASKER
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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
oBdA

You might want to add the /xo (eXclude Older) switch to the robocopy command then, to make sure only the latest file is copied.
Siddharth S

ASKER
Thanks guys, solved it. Great help as usual.