Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 我需要一种只计算奇数行的代码格式_Batch File - Fatal编程技术网

Batch file 我需要一种只计算奇数行的代码格式

Batch file 我需要一种只计算奇数行的代码格式,batch-file,Batch File,test_title.bat :GET_DOWNLOADS set Counter=-1 for /f "DELIMS=" %%i in ('type version.txt') do ( set /a Counter+=2 set "Line_!Counter!=%%i" ) if exist version.txt del version.txt exit /b :list_files call :GET_DOWNLOADS For /L %%C in (1,2,%Counter%) Do

test_title.bat

:GET_DOWNLOADS
set Counter=-1
for /f "DELIMS=" %%i in ('type version.txt') do (
set /a Counter+=2
set "Line_!Counter!=%%i"
)
if exist version.txt del version.txt
exit /b

:list_files
call :GET_DOWNLOADS
For /L %%C in (1,2,%Counter%) Do (
:: removing this part makes it work fine
set line=%%C
set /a line+=1
set /a line/=2
:: alternate way doesnt work either
REM set /a line=%line% / 2
:: this part without the math part would be %%C instead of %Line%
echo %line%. !Line_%%C!
)
pause
(编辑) 由于某种原因,第二部分不起作用 它只是崩溃了 如果我删除进行数学运算的行,它工作正常,但显示1。3.5.七,

version.txt

everything
0
minecraft
0
steam
0
obs
0
固定测试列表。bat:D

@echo off
setlocal enabledelayedexpansion
set "num=1"
set "counter=0"
for /f "DELIMS=" %%i in (version.txt) do (
set /a num+=1
if "!num!"=="2" (set /a counter+=1&set "line_!counter!=%%i"&set num=0)
)

echo.

For /L %%C in (1,1,%Counter%) Do (echo %%C. !Line_%%C!)

pause
将输出:

一切
地雷船
蒸汽
obs

第1行=所有内容
第2行=地雷船
第3行=蒸汽


这是整个脚本。一个美妙的开始,但我需要它来实际保存这些输出到!行%Counter%!我做到了,顺便说一句,谢谢你的帮助:D我一直在努力解决这个问题,我正在做一些大的事情,我尽量不硬编码,这样很容易改变。因此,我下载1 version.txt,其中将包括程序的名称和版本号:D它的托管地址(我还没有将程序下载程序具体设置为tho)只知道我所做的一切都不漂亮一开始我比代码开发更擅长快速原型设计lol
@echo off
setlocal enabledelayedexpansion
set "num=1"
set "counter=0"
for /f "DELIMS=" %%i in (version.txt) do (
    set /a num+=1
    if "!num!"=="2" (set /a counter+=1&set "line_!counter!=%%i"&echo %%i&set num=0)
)

echo.
set line_1
set line_2
set line_3

pause