I have a file with a list of paths. Some of them might include environment variables such as %USERPROFILE%
.
Example:
%USERPROFILE%\dir
C:\another\dir
I'm then reading all the lines and concatenating with ;
using this code (the cat and tr commands are available because of git):
set include_file=C:\path\to\file.txt
for /f "delims=" %%i in ('cat %include_file% ^| tr "\\n" ";"') do set include_content=%%i
This creates a variable with the string %USERPROFILE%\dir;C:\another\dir
Normally running echo %USERPROFILE%
would give you something like C:\Users\xxx\dir
but running it with %include_content%
just outputs the original string without expanding %USERPATH%
My final plan is to add the directories to my PATH like this set PATH=%include_content%;%PATH%
but this doesn't work since the variable isn't expanded.
My question is can I somehow expand the variables in the string so that the real directories get added to the path?