Solved

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

Posted on 2008-10-10
4
4,215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

919 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

15 Experts available now in Live!

Get 1:1 Help Now