assign a text file's find output to a variabl

February 4, 2010 at 09:34:54
Specs: Windows 2003
hi all,

i have a text file and I need to assign the output to a variable. I have tried the following command but not working

set /P = < type C:\test.txt

See More: assign a text files find output to a variabl

February 4, 2010 at 09:52:56
set /P myvar=< test.txt

Beware just the first line is saved into the variable.

Report •

February 4, 2010 at 10:06:11
Hmm, never done that before because you could over run your memory. Why do you need it in a memory variable instead of a file?

If you have to do it then try this in a script...

@echo off
Set MyVar=
For /F "tokens=* delims= " %%A in (small.txt) do (
  call :setvar %%A)
echo %MyVar%
goto :eof

set MyVar=%MyVar% %1
goto :eof

Now variables can not support (Tabs and Carriage Returns) so they will be stripped out. So again I have to ask what are you doing that you need to do this?

Report •
Related Solutions

Ask Question