# looping xcopy



## displaced (Mar 16, 2007)

Hello,

I do alot of training and set up training files, now most of the time these haave to be copied locally to every machine...which before hand i have done manually...when i suddenly thought "there must be an easier way" so i started looking and ive managed to patch this code togeter which does the job.....


```
@echo off & setlocal
set FN="\\server\support\3dsmax 9 essentials"
for %%c in ("\\training1\desktop-training\3DMax 9 Esentials" "\\training2\desktop-training\3DMax 9 Esentials" "\\training3\desktop-training\3DMax 9 Esentials" "\\training4\desktop-training\3DMax 9 Esentials") do xcopy %FN% %%c /s /e /i /y /exclude:exclude.txt /w
```
but what i would like to do is make a nice flash front end for this and pass the source location and destinations to it....now im wondering how to do this...

this is where im upto now.


```
@echo off & setlocal

:loop

set FN="%1"
for %%c in ("\\%2\desktop-training\3DMax 9 Esentials") do xcopy %FN% %%c /s /e /i /y /exclude:exclude.txt /w

if %1 =="" goto loop
shift
```
then calling the batch and passing the variables to it

xcopytraining.bat "\\server\support\3dsmax 9 essentials" "training1 training3 training7"

but this isnt working.....

please guys help me out


----------



## html81993 (Jul 8, 2005)

I don't think you need to type the quotes on the command line. Try removing the quotes and trying again.


----------



## displaced (Mar 16, 2007)

Hi thanks for your reply

yes it made sense to take out the quote marks on the command line from around the destinations

this is where im up to now....but the script just does nothing

it reads like it should work but no idea where im going wrong with this one...


```
set FN=%1

:loop

do xcopy %FN% "\\%2\desktop-training\3DMax 9 Esentials" /s /e /i /y /exclude:exclude.txt /w

if %2 =="" goto loop
shift
```


----------



## html81993 (Jul 8, 2005)

displaced said:


> ```
> set FN=%1
> 
> :loop
> ...


Are the two quotes after %2 placeholders to let you know its empty? Again, try removing them. Also, the "/s" and "/e" switches contradict themselves. "/s" means to copy everything except for empty directories, while "/e" means to copy everything including empty directoires. Remove the one you don't want.


----------



## html81993 (Jul 8, 2005)

Is this program going to be copying a set file or directory, lets say "C:\tocopy.txt" or "C:\Tocopy" to different directories, like the "A:\" drive?


----------

