Solved

How do I Xcopy to multiple destinations using a list in a .txt file?

Posted on 2008-10-10
4
4,189 Views
Last Modified: 2012-02-28
Machine - XP  
Server - 2003

Trying to run an Xcopy to copy a folder from a single server to multiple servers.  Would like to have the server list on a text document rather than imbedded in the xcopy.

This is the general idea of what I am trying to do, but it just tries to copy to "\\c:\svrlst.txt\vol1\installs"
for %%a in (c:\svrlst.txt) do xcopy c:\folder \\%%a\vol1\folder /e /i

---svrlst.txt---
server1, server2, server3
----------------

I know the following line works, but I would like the list in a txt file that is easier to manage:
for %%a in (server1, server2, server3) do xcopy c:\folder \\%%a\vol1\folder /e /i
0
Comment
Question by:craigshaf
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
robsantos earned 125 total points
ID: 22689082
does this help?

http://www.experts-exchange.com/Programming/Languages/Scripting/Q_23141541.html

(looks like you may be missing a "/f" after your "for" statement, like:

for /f %%a in......
0
 
LVL 15

Expert Comment

by:tenaj-207
ID: 22689127
You could use the set command in your batch file.  the batch file would look like this.

Set svr1=server1
set svr2=server2
set svr3=server3

xcopy c:\folder \\svr1\vol1\folder /e /i
xcopy c:\folder \\svr2\vol1\folder /e /i
xcopy c:\folder \\svr3\vol1\folder /e /i
0
 

Author Closing Comment

by:craigshaf
ID: 31505081
Thank You - one little /f off, and pow, it worked.  Also had to change the list to a single column and ditch the commas
0
 

Author Comment

by:craigshaf
ID: 22689146
Thanks tenaj, not exactly what I was looking for.  the /f switch made the difference I needed.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now