Page 1 of 1

how to display all lines in an txt file as a variable

Posted: 12 Dec 2020 13:45
by rasil
Hi!,
I am having some problems loading a txt file line by line and then being able to save all that information into a variable. i have tried this

Code: Select all

FOR /F %%i IN (log.txt) DO ECHO %%i
but it only displays text before an space. The text inside log.txt has spaces so i would like to desplay the full length of text.

Rasil

Re: how to display all lines in an txt file as a variable

Posted: 12 Dec 2020 15:18
by aGerman
Default delimiters are space and tab as discribed in the help text of FOR.

Code: Select all

FOR /F "delims=" %%i IN (log.txt) DO ECHO %%i
However, blank lines are still skipped. Lines beginning with a semicolon, too.
What about ...

Code: Select all

type "log.txt"
Steffen

Re: how to display all lines in an txt file as a variable

Posted: 12 Dec 2020 17:33
by rasil
Worked perfectly thanks Steffen! :D