Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

171.10.2.2 
171.10.3.2
etc.

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

share|improve this question

1 Answer 1

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

 
discard

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.