Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to create a Windows XP batch file to copy files from a series of computers into a directory on another machine.

I've a text file with our internal LAN IPs like this:

I have to copy all files from : \\\c$\mydir\*.txt to \\myserver\mydir

share|improve this question
up vote 0 down vote accepted

for /f can iterate over lines in a file. xcopy can use UNC paths when copying.

Take the following as a starting point:

for /f %%x in (ips.txt) do xcopy \\%%x\C$\mydir\*.txt \\myserver\mydir

If you need a specific user/password on the other server I think the only good way to do would be to mount those as drives:

for /f %%x in (ips.txt) do (
    net use X: \\%%x\C$ <password> /user:<username>
    xcopy X:\mydir\*.txt Y:\
    net use X: /DELETE
share|improve this answer
Thank you. I've only one problem: can i insert my user and password (user credentials) to prevent the request by the client and server ? Thanks – stighy Mar 29 '11 at 12:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.