| 1. |
Solve : Exclude space as delimiter in a list? |
|
Answer» Eventually this BATCH file will expand to allow selection of creation of a range of subdirectories, however I've got to get the code correct first. 1. Use quotes around list items. Well that worked. Many thanks Salmon Trout. He Da MAN... A technical explanation, in case anyone is interested (might HELP some readers)? In a simple FOR loop, for %%V in (dataset) do... if dataset is a list, separated by standard delimiters (space, comma, semicolon) then each time around the loop %%V will hold, one after the other, each item in the list. Thus: for %%A in (1,2,3) do echo %%A for %%A in (1 2 3) do echo %%A for %%A in (1;2;3) do echo %%A will all output 1 2 3 Quotes around list items allow the item to contain standard delimiters, e.g. spaces. The quotes become part of the variable string. for %%A in ("1 2" "3,4" 5 6 7; do echo %%A "1 2" "3,4" 5 6 7 8 If you want to strip the quotes, then, in the loop, use a tilde (~) before the loop variable like so for %%A in ("1 2" "3,4" 5 6 7; do echo %%~A 1 2 3,4 5 6 7 8 and, of course, dataset can be a variable: set MyList="1 2" "3,4" 5 6 7;8 for %%A in (%MyList%) do echo %%A "1 2" "3,4" 5 6 7 8You can use a list separated by LINE endings: for %%A in ( "2010-11 FY" "2011-12 FY" "2012-13 FY" "2013-14 FY" "2014-15 FY" "2015-16 FY" "2016-17 FY" "2017-18 FY" "2018-19 FY" "2019-20 FY" ) do echo mkdir %%A |
|