Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch file to copy a file to multiple computers by iteration?

I have below batch script to copy file from my computer to many computers.

@echo off

xcopy D:\some.txt \\10.124.66.72\texts

xcopy D:\some.txt \\10.294.66.46\testfolder

pause

In the script, i have mentioned all the other computer names/IPs. Now how can i keep other computer names in a separate text file and iterate them in batch file instead writing xcopy command many times? Or is it possible to mention list of computers, iterate through all and use single xcopy command?

like image 801
user755806 Avatar asked Mar 19 '23 22:03

user755806


1 Answers

Try this:

FOR /F "delims=" %%i IN (targets.txt) DO (
 xcopy "D:\some.txt" "%%i"
)

targets.txt should contain entries like "\\10.124.66.72\texts" in each line

like image 186
MichaelS Avatar answered Apr 08 '23 06:04

MichaelS