:getVarsByAttr

returns a comma separated list of variables based on an attribute name

Description: call:getVarsByAttr attr ret
Script:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
:getVarsByAttr attr ret -- returns a comma separated list of variables based on an attribute name
::             -- attr [in]  - attribute name
::             -- ret  [out] - reference to return variable
:$created 20060101 :$changed 20080219
:$source https://www.dostips.com
SETLOCAL
set varattr=%~1
set value=
FOR /F "usebackq tokens=1,2 delims=.=" %%a IN (`set`) DO if "%%a"=="%varattr%" (set value=!value!%%b,)
( ENDLOCAL & REM RETURN VALUES
    IF "%~2" NEQ "" SET %~2=%value%
)
EXIT /b