1.

Solve : Read text file and save to a variable?

Answer»

Hi All,

I'm new to batch and I want to automate my NUnit Script to be dynamic. I'll explain this in a basic question.

My text file contains

     test1
     test2
     test3

I want to read those multiple LINES and save it into a variable. Here's my current script

for /f "delims=" %%x in (test.txt) do set params=%%x

Though I'm only getting the last line which is test3. I want this OUTPUT:

test1 test2 test3


Code: [Select]echo off
setlocal enabledelayedexpansion
set "params="
For /f "delims=" %%x in (test.txt) do set "params=!params!%%x "
Squashman wow you woke up hungry....

How ya been ? Quote from: patio on March 27, 2021, 05:45:28 AM

Squashman wow you woke up hungry....

How ya been ?
PRETTY Good.  Staying Safe. I doubt any of the original users will come back to all the questions I answered but at LEAST they have an answer for posterity's sake.


Discussion

No Comment Found