0

If my text document simply contains "hello" and nothing else, how do I set that to a variable WITHOUT a for loop? So I don't want you to say "You can use "for /f %%A in ('type C:...\test.txt') do set var=%%A" That's not what I want. I think I need to use <, >, or something to do it. How

user3762093
  • 33
  • 1
  • 6

1 Answers1

1

You can set a variable to the first line of a text file (or the only line in your case) with set /p.

For example, if your text file is source.txt, you can use

@echo off
set /p var=<source.txt
echo %var%
SomethingDark
  • 13,229
  • 5
  • 50
  • 55