dos batch copy command

What is wrong?
for /L %%c in (1, 1, 23) do (
echo Processing:"chr%%c.tped"
set src=U:\Analysis\201104\epistasis\CGEMS\add_33_tped
copy chr%%c.tped+CGEMS33SNPs.tped %%src%%\chr%%c.tped
)
echo off
pause

Open in new window

zhshqzycAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Double % are used with for variables only.  Not standard variables.
      

for /L %%c in (1, 1, 23) do (
echo Processing:"chr%%c.tped"
set src=U:\Analysis\201104\epistasis\CGEMS\add_33_tped
copy chr%%c.tped+CGEMS33SNPs.tped %src%\chr%%c.tped
)
echo off
pause

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
Also, there is a line inside the loop that typically would be outside the loop, since it doesn't change.  You'll improve performance slightly by keeping things that don't change during the loop outside of it, like this.

In addition, if src did change inside the loop, you need to use !src! to reference it, and add a setlocal EnableDelayedExpansion line to the top of the bat script.

set src=U:\Analysis\201104\epistasis\CGEMS\add_33_tped
for /L %%c in (1, 1, 23) do (
  echo Processing:"chr%%c.tped"
  copy chr%%c.tped+CGEMS33SNPs.tped %src%\chr%%c.tped
)
pause

Open in new window

~bp
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.