0

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

1 Answer 1

0

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
)
1
  • 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, 2011 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .