Page 1 of 1

How can I make SET to set a variable based on txt content?

Posted: 28 Feb 2010 13:13
by keropi
Hiya!

is there a way to make SET create a variable from a small txt ?
let's say I have 1.txt that has inside: 123
and I want to make a variable, let's say: TEST1
so is there a way to make a batch file to SET TEST1=1.txt_content
so I get TEST1=123
??

Re: How can I make SET to set a variable based on txt content?

Posted: 28 Feb 2010 14:57
by aGerman

Code: Select all

set /p "TEST1="<"1.txt"


Regards
aGerman

Re: How can I make SET to set a variable based on txt content?

Posted: 28 Feb 2010 17:06
by keropi
I did it and the result was this variable:
/P "test1="
I guess plain dos from win98se does not get this command... :cry:

Re: How can I make SET to set a variable based on txt content?

Posted: 01 Mar 2010 03:51
by keropi
OK I have found this solution that works in plain old DOS:

Code: Select all

@echo off
echo @echo off> director.bat
echo set getdir_=%%2>> director.bat
echo echo %%getdir_%%>> director.bat
dir | find "Directory"> go.bat
call go
if exist director.bat del director.bat
if exist go.bat del go.bat


getdir_ is the variable, edit it to whatever name you want :mrgreen: