Skip to content

Instantly share code, notes, and snippets.

@froop
Created June 22, 2011 00:46
Show Gist options
  • Select an option

  • Save froop/1039293 to your computer and use it in GitHub Desktop.

Select an option

Save froop/1039293 to your computer and use it in GitHub Desktop.
[bat] ファイルから入力した各行に同じ処理をするサンプル for Windows
set LIST_FILE=list.txt
set TARGET_PROC=sample.bat
rem カレントディレクトリを保存
for /F %%a in ('cd') do set ROOT_DIR=%%a
rem ファイルの行数分繰り返し
for /F %%i in (%LIST_FILE%) do call :loop %%i
goto :end
rem ループの中身
:loop
cd %1
if errorlevel 1 goto :end
call %TARGET_PROC%
if errorlevel 1 goto :end
cd %ROOT_DIR%
exit /b
:end
cd %ROOT_DIR%
pause
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment