Robocopy to reference a text file

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
doctorbillTechAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
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

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
doctorbillTechAuthor 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......
0
Shaun VermaakTechnical SpecialistCommented:
Yes, you still need to do the other parts
0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

doctorbillTechAuthor Commented:
what parts are those
0
NVITEnd-user supportCommented:
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.
0
doctorbillTechAuthor Commented:
ok - will try it
0
doctorbillTechAuthor Commented:
sorry - does not work
0
NVITEnd-user supportCommented:

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.
1
ReneGeCommented:
@DoctorBill

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

\\isi-sbs2011\File1 is source folder?
e:\isi-data\File1 is destination folder?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.