octavian-nita
12/4/2013 - 9:04 PM

Batchfile template

Batchfile template

@if "%DEBUG%"=="" @echo off
setlocal enabledelayedexpansion

:: =====
:: Command line arguments check:
:: =====
if [%1]==[] (
  echo Usage: %0 arg-1 [arg-2] ...
  exit /b 1
)

:: Setting / modifying variables in loops -- example (TODO: remove this and place it into a gist):
::
:: set CLASSPATH=WEB-INF\classes
:: for /f %%F in ('dir /b %LIBDIR%') do (
::   set CLASSPATH=!CLASSPATH!;%LIBDIR%\%%F
:: )

:: Delete myself :) ...
:: start /b "" cmd /c del "%~f0"&exit /b

endlocal
exit /b %ERRORLEVEL%