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

Joey
  • 1,853
  • 11
  • 13
stighy
  • 931
  • 8
  • 21
  • 32

1 Answers1

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
)
Joey
  • 1,853
  • 11
  • 13
  • 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