[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Dos echo command issue

Posted on 2014-08-20
Medium Priority
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
ID: 40275348
Take out the echo.and try
LVL 84

Expert Comment

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

missing a plus
LVL 71

Accepted Solution

Qlemo earned 2000 total points
ID: 40275584
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Suggested Courses

834 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