Solved

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

Posted on 2008-10-10
4
4,354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Winapi.Windows.hpp problem 7 44
Windows Update Could Not Search for New Updates (C8000266) 11 321
.JSD files... 2 34
Backup Software for Windows 7 9 65
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Configuring Remote Assistance for use with SCCM
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

734 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