I have a very simple problem in windows batch programming, yet I did not find the answer in the existing questions.
I want to fill the content of 3 variables with input from a text file (3 lines, one for each variable), and use
set /p. But it seems this works only for the first line, not the others.
Here is a reproducible example:
I launch this batch file (test.bat):
@echo off ( set /p Line1= set /p Line2= set /p Line3= )<%1 echo I read the following parameter from your %1 config file: echo -- Content of line 1: %Line1% echo -- Content of line 2: %Line2% echo -- Content of line 3: %Line3%
The argument file is test.txt:
The line 1 The line 2 The line 2 copied
Then, I just launch
'test.bat test.txt', with the following result:
I read the following parameter from your test.txt config file:
-- Content of line 1: The line 1 -- Content of line 2: -- Content of line 3:
Why do the lines 2 and 3 from test.txt are not takken up and the correspnding variables line2 and line3 empty?
I can reproduce your problem if
test.txt contains Unix line breaks
0x0A, and it works if it contains windows line breaks (
0x0D 0x0A). So if that is also the source of your problem convert the line breaks in your