@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
是我的代码,但输出是
C:\ Users \用户家庭\桌面\ saxcz \ find.bat:集 XX
为什么会这样?
答案 0 :(得分:1)
不确定我是否理解您尝试实现的任务,但这可能会有所帮助
@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