2017-03-29 18 views
0

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. 7.

version.txt

everything 
0 
minecraft 
0 
steam 
0 
obs 
0 

固定test_list.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 
+0

這是整個腳本。 – MarioMasta64

回答

0
@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 

將輸出:

一切
的Minecraft
蒸汽
OBS

LINE_1 =一切
LINE_2 =的Minecraft
line_3 =蒸汽

+0

一個美好的開始,但我需要它來實際保存這些輸出!Line_%Counter%! – MarioMasta64

+0

@ MarioMasta64查看更新的答案 – samdd

+0

我做了,順便說一句,謝謝你的幫助:D我被困在試圖找出這個最長的 – MarioMasta64