Copy one file to multiple directories

Question:

I need to be able to copy one file to multiple directories, the only problem is the multiple directories have item that is unknown.

So I have a file that is located in c:\folder1\somefile.txt

I want to copy this file to the users home directories:

\\server\homes\user1\folder1\
\\server\homes\user2\folder1\
\\server\homes\userA\folder1\
\\server\homes\userX\folder1\
\\server\homes\user5\folder1\ …..

Everything is the same except the user name changes

How can this be done on Windows server 2003.

There was another similar to this and was suggested to add to the logon script, this is not the solution I am looking for.

I started writing a batch file:

XCOPY c:\folder1\somefile.txt \\server\homes\<HAVE NO CLUE WHAT TO PUT IN HERE>\folder1\

Even if there is a command that extract and export a list of the directories that have “folder1″ I’m guessing I could then put them in the destination somehow?

Solution:

@echo off
setlocal

for /f  %%D  in (‘dir/ad/b “\\server\homes”‘) do  XCOPY  “c:\folder1\somefile.txt”  “\\server\homes\%%D\folder1\”

Từ khóa:
digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb