|
Answer» Ex. code in c for apending valuse in varible is
a =+ b;
if i try this in batch files like path=+%%val and if the value of val is test then
It shows like path = +testalwhats the question?APPENDING to a text file or any file you need the redirection charachter in a batch file its > so echo line>file.txt or INPUT>output.txt using a single redirection charachter would re-write all lines in the file you are appending to and REPLACE it with the new line, if you want to add multiple lines use two redirection charachters >>
echo firstline>output.txt echo secondline>>output.txt echo thrirdline>>output.txti want to append value in variable , not in file.so you just need to set a variable?
if you need multiple lines you need to set for in an array but if you want a single line you can just use the for statement
for /f "tokens=1*" %a in (mytext.file) do set a=%a
say you needed multiple lines set into variables like the output of the dir command
set c=0 for /f "tokens=1*" %a in (dir/a) do ( call set c=%%c%%+1 call set a.%%c%%=%a ) I do something like follwing
for /f "tokens=1-10 delims=\" %%1 in ('cd') do ( set p=%%1 set c=1 :bof if %%c==tools_v2 goto :eof set p.%%p%%=%%c set c=%%c%%+1 goto :bof ) :eof echo Path = %p%
i want to add each value of c variable in p till test is matched with the value of c
line in bold want to be change
do u understand what i want ?hi diablo416
finally i used following code and want to append valuse of g in p varibale can u help me how can i do this:
for /f "tokens=1-10 delims=\" %%1 in ('cd') do ( set p=%%1 for %%G in (%%1, %%2, %%3, %%4, %%5, %%6, %%7, %%8, %%9, %%10) do ( if %%G==test echo %p% set p=................. echo %%G )
)
where i wrote echo %%g at that point i have to append value of g in p so that i can get FULL path.
|