budchawla
asked on
Loop in a batch file, and increment a UNC path
Hi ..
I need to copy a file from my server onto 50 computers, each one is named computer-01, computer-02... computer-50.
How can I do this via a batch file without copy/pasting the line 50 times?!
copy \\server\file.xyz \\computer-01\c$\progra~1\ whateverfo lder\
I'm sure this is quite simple, but I haven't got a massive amount of experience with batch file scripting!
Thanks!
I need to copy a file from my server onto 50 computers, each one is named computer-01, computer-02... computer-50.
How can I do this via a batch file without copy/pasting the line 50 times?!
copy \\server\file.xyz \\computer-01\c$\progra~1\
I'm sure this is quite simple, but I haven't got a massive amount of experience with batch file scripting!
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
funny thing, if I run the command itself from the prompt, no problem...
ASKER
aha... if I type the whole filename at the prompt, (type in md.bat rather than just md) I get a different message:
n was unexpected at this time.
Any ideas?
n was unexpected at this time.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also, do you know of a good syntax reference for this kind of thing?
Sorry inserted extra space in your md command:
for /l %%n in (1,1,8) do if not exist "dir%%n" md dir%%n
Added a check to see if the directory exists to make up for my mistake :)
for /l %%n in (1,1,8) do if not exist "dir%%n" md dir%%n
Added a check to see if the directory exists to make up for my mistake :)
ASKER
aha .. that's it, thanks SteveGTR...
You can type /? for any command on the command prompt. For example:
for /?
or
if /?
I use that all the time. Also, this site has a bunch of good information on batch processing:
http://www.robvanderwoude.com/index.html
for /?
or
if /?
I use that all the time. Also, this site has a bunch of good information on batch processing:
http://www.robvanderwoude.com/index.html
You can type "help for" at the command prompt and it will tell you all the syntax
ASKER
thanks guys.. both resources useful!
ASKER
All makes sense to me.. but I just tried it by creating a batch file in the root of c: with the following:
for /l %n in (1,1,8) do md dir%n
exactly as you said, and I get a message saying the syntax of the command is incorrect?