@echo off REM %1 prefix (specifying 'no_prefix' will omit the prefix REM %2 postfix (if not specified postfix is omitted) REM REM A bracketed list is made of the numbers 0 through 9, each preceded REM by the prefix and followed by the postfix. The result is stored in the REM environment variable 'list'. REM REM makelist no_prefix : list = (0 1 ... 9) REM makelist no_prefix b : list = (0b 1b ... 9b) REM makelist a : list = (a0 a1 ... a9) REM makelist a b : list = (a0b a1b ... a9b) REM REM Restriction: REM The directory where this file is located should be present in the REM path to allow a recursive call. REM 'addunit' cannot be used as prefix (used for the recursive call). if "%1" == "addunit" goto new_unit set list_nrs=(0 1 2 3 4 5 6 7 8 9) if not "%1" == "no_prefix" set list_pre=%1 set list_post=%2 set list=( for %%i in %list_nrs% do call makelist addunit %%i set list=%list%) goto cleanup :new_unit set add= %list_pre%%2% if "%list%" == "(" set add=%list_pre%%2% set list=%list%%add% set list=%list%%list_post% goto exit :cleanup set add= set list_nrs= set list_pre= set list_post= :exit