Robocopy to reference a text file

doctorbill
doctorbill used Ask the Experts™
on
Robocopy

Can someone please give me a script that allows me to robocopy a lot of directories from a source to a destination while referencing the directory names listed in a text file
The list will be in c:\scripts
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
Sadly, RoboCopy has no option to allow for providing a list of folders. You have to use a batch file, copying one folder each time.
I'm assuming your file contains both source and destination paths, separated by a comma:
@echo off
for /f "tokens=1-2 delims=," %%A in (C:\Scripts\Folders.txt) do robocopy %%A %%B /S /R:1 /W:1

Open in new window

Author

Commented:
The file just has the file name from the source

So should this be the format:
\\isi-sbs2011\File1,e:\isi-data\File1
\\isi-sbs2011\File2,e:\isi-data\File2
\\isi-sbs2011\File3,e:\isi-data\File3
etc......
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2018

Commented:
Yes, you still need to do the other parts
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Author

Commented:
what parts are those
NVITEnd-user support

Commented:
Save your list as C:\Scripts\Folders.txt:
\\isi-sbs2011\File1,e:\isi-data\File1
\\isi-sbs2011\File2,e:\isi-data\File2
\\isi-sbs2011\File3,e:\isi-data\File3

Open in new window

Then run Qlemo's code.

Author

Commented:
ok - will try it

Author

Commented:
sorry - does not work
NVITEnd-user support

Commented:

sorry - does not work
is not very helpful for us.

How did you run it?
1. Change the code to:
@echo off
for /f "tokens=1-2 delims=," %%A in (C:\Scripts\Folders.txt) do ECHO robocopy %%A %%B /S /R:1 /W:1

Open in new window

2. Save it to a file like test.cmd
2. Open a CMD window
3. Run test.cmd
4. Copy and pasted the CMD window text here for us to review.

Commented:
@DoctorBill

In:
\\isi-sbs2011\File1,e:\isi-data\File1

\\isi-sbs2011\File1 is source folder?
e:\isi-data\File1 is destination folder?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial