07-23-2023, 10:49 AM
We have a text file that lists a bunch of paths, and a batch file that reads the lines from this file.
For instance, TargetFolders.txt might contain the line:
%ProgramFiles%\Acme\FooBar %VersionNumber%
Naturally, when we read this line from the text file (using a FOR command), the variable %%I receives the actual line text, with the % signs rather than replacing the variable values. So,
SET VersionNumber=7.0
FOR /F "eol=; delims=" %%I IN (TargetFolders.txt) DO (
echo Folder: %%I
)
Prints
Folder: %ProgramFiles%\Acme\FooBar %VersionNumber%
How does one make it replace the actual variable values, so that it prints
Folder: C:\Program Files\Acme\FooBar 7.0
?
For instance, TargetFolders.txt might contain the line:
%ProgramFiles%\Acme\FooBar %VersionNumber%
Naturally, when we read this line from the text file (using a FOR command), the variable %%I receives the actual line text, with the % signs rather than replacing the variable values. So,
SET VersionNumber=7.0
FOR /F "eol=; delims=" %%I IN (TargetFolders.txt) DO (
echo Folder: %%I
)
Prints
Folder: %ProgramFiles%\Acme\FooBar %VersionNumber%
How does one make it replace the actual variable values, so that it prints
Folder: C:\Program Files\Acme\FooBar 7.0
?