Reputation: 21
@echo off
set result=""
setlocal enabledelayedexpansion
for /f %%i in ('FINDSTR /I /S /C:"A=1" C:\Users\Family\Desktop\saxcz find.bat')
do set result=%%i
)
echo !result!
) else (
echo xx
)
pause>nul
is my code but the output is
C:\Users\Family\Desktop\saxcz\find.bat:set xx
why is this happening?
Upvotes: 2
Views: 1153
Reputation: 1705
Not sure if I understand the task you try to achieve, but this may help
@echo off
setlocal enabledelayedexpansion
set "result="
set/a offset=0
for /f "tokens=3,4 delims=:" %%i in ('FINDSTR /N /I /S /C:"A=1" C:\Users\Family\Desktop\saxcz\find.bat') do (
set/a offset+=1 & set "line=0000%%i"
set "result[!offset!]=!line:~-4! %%j"
)
if %offset% neq 0 (
echo(
echo(Line data
echo(---- ---------------------------------
for /L %%i in (1,1,%offset%) do echo(!result[%%i]!
echo(---------------------------------------
echo(
echo( %offset% items found
) else (
echo(Not found
)
endlocal
exit/B
Upvotes: 1