batch-file Variables in Batch Files Declare multiple variables

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

When multiple variables are defined at the beginning of the batch, a short definition form may be used by employing a replacement string.

@echo off
set "vars=_A=good,_B=,_E=bad,_F=,_G=ugly,_C=,_H=,_I=,_J=,_K=,_L=,_D=6
set "%vars:,=" & set "%"

for /f %%l in ('set _') do echo %%l
exit /b

_A=good
_D=6
_E=bad
_G=ugly

Note in the above example, variables are natively alphabetically sorted, when printed to screen.



Got any batch-file Question?