tags:

views:

257

answers:

1

how to get the output in column wise in a below batch file

@echo off
setlocal enableextensions enabledelayedexpansion
set Counter=0
for /f "usebackq tokens=2,5,6 delims= " %%a in (`findstr /c:"Cod " 

1231.txt`) do (        
set x=%%b
set x=!x:~3!
set y=%%c        
if %%c LSS 10 set y=!y:~1!
set item!Counter!=%%a-!x!#!y!        
set /a Counter+=1
)
set result=%item0%
for /l %%i in (1,1,!Counter!) do set result=!result!!item%%i!
FOR /F %%A IN ('CHCP') DO SET CHCP=%%A
echo  %result% >>result.txt
endlocal
+1  A: 

Looks like you are concatenating the values into the result variable. Rather than:

... do set result=!result!!item%%i!

Why not output the value directly to your output file:

... do echo !item%%i!>>result.txt
Dave Cluderay
thank you I added the syntax what you give me. but inresult first line skipping. means i need to get the result 660-936330#9 660-936340#10ut it is notgiving result from first line it is giving from 2nd line only.
That's alright. The line above (set result=%item0%) was covering that first one.Change it to: echo %item0%>result.txt
Dave Cluderay
Or instead, change the original line to:for /l %%i in (0,1,!Counter!) do echo !item%%i!>>result.txt
Dave Cluderay