「batファイル」for文で数値をインクリメント(Increment)するサンプル

書式
setlocal enabledelayedexpansion
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@echo off
setlocal enabledelayedexpansion
set m=0
for /l %%n in (2,2,10) do (
set /a m=m+1
echo ループ回数:!m!
echo study skill in arkgame.com and become strong
)
endlocal
@echo off setlocal enabledelayedexpansion set m=0 for /l %%n in (2,2,10) do ( set /a m=m+1 echo ループ回数:!m! echo study skill in arkgame.com and become strong ) endlocal
@echo off
 
setlocal enabledelayedexpansion
set m=0

for /l %%n in (2,2,10) do (
  set /a m=m+1

  echo ループ回数:!m!
  echo study skill in arkgame.com and become strong
 )
 
endlocal

実行結果
ループ回数:1
study skill in arkgame.com and become strong
ループ回数:2
study skill in arkgame.com and become strong
ループ回数:3
study skill in arkgame.com and become strong
ループ回数:4
study skill in arkgame.com and become strong
ループ回数:5
study skill in arkgame.com and become strong

batch

Posted by arkgame