Dos echo command issue

Posted on 2014-08-20
Last Modified: 2014-08-21
windows 7 pro machine

Given t.bat  

for /l %%x in (2, 1, 15) do (echo."StationNumber=%%x" 1> edge2%%x%.txt
for /l %%y in (2, 1, 3) do (

echo.copy a.txt +edge2%%y%.txt +b.txt edgex%%y%.txt >>x.txt

when I execute t.bat from a command prompt I get in x.txt

copy a.txt +edge22.txt
copy a.txt +edge23.txt

why am I not getting
copy a.txt+edge22.txt+b.txt edgex22.txt  
copy a.txt+edge23.txt+b.txt edgex23.txt


Please don't give me vbs or other programming languages.. I want to know why this is not working in a bat file.
Question by:HalCHub
    LVL 13

    Expert Comment

    by:Gabriel Clifton
    Take out the echo.and try
    LVL 77

    Expert Comment

    by:David Johnson, CD, MVP
    echo.copy a.txt +edge2%%y%.txt +b.txt + edgex%%y%.txt >>x.txt

    missing a plus
    LVL 67

    Accepted Solution

    Nope, the additional plus is wrong too.
    You must not add a % after FOR variables.
    You also don't need the parens inside the FOR loop, but that is cosmetical.
    for /l %%x in (2, 1, 15) do echo."StationNumber=%%x" 1> edge2%%x.txt
    for /l %%y in (2, 1, 3) do echo.copy a.txt +edge2%%y.txt +b.txt edgex%%y.txt >>x.txt

    Open in new window


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    I hope this helps those who have been battling the SanDisk / U3 problem for a while. For anyone that is running Windows 7 64bit and is receiving and searching the internet for the “Windows Error: Windows has allocated a drive letter to the U3 dri…
    So many times I have seen the words written in a question "if only I could show you" or " I know how hard it is for you since you can't see it" in any zone. That has inspired me to write about this tool in windows 7 called "Problem Steps Recorder…
    This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
    The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now