Set an environment variable from a text file contentTag(s): Misc Prog HowTo


Let's say we have the following text file.

[howto.txt]

this is an interesting howto
This batch file will read the given file and set the environment variable content with the file content.

[howoto.cmd]

@echo off
SetLocal EnableDelayedExpansion
set content=
for /F "delims=" %%i in (howto.txt) do set content=!content!%%i
echo %content%
EndLocal
gives this output
> howto.cmd
this is an interesting howto

blog comments powered by Disqus