Reputation: 381
I have a config file with some configurations and I read the contents of the file into a batch script using the below command
for /f "delims=" %%x in (configurations.config) do (set "%%x")
There are a few comments (starting with '#') in the config file which I don't want to be read while parsing the file in my batch script.
Is there a way to do that?
Thanks.
EDIT
Sample config file:
#This is the comment. var1=value1 var2=value2
The error I get is
Environment variable #This is a comment. not defined
Upvotes: 0
Views: 458
Reputation: 34919
The for /F
command features an opetion eol
to define one character that tells to not process a line if it begins with it (type for /?
in a command prompt window and read the help text for more):
for /f "eol=# delims=" %%x in (configurations.config) do (set "%%x")
The default option is eol=;
. Note that the defined character must be the very first one in the line, there are not even any preceding white-spaces allowed.
Upvotes: 2