http://www.dostips.com/forum/posting.php?mode=quote&f=3&p=16763
So try this.Code: Select all
@echo off
> file.txt echo ,,,!value1!,value2 opt,,,value3,,value4 opt,,,value5,,,,,
> file.txt echo ,,,!value1!,value2 opt,,,value3,,value4 opt,,,value5,,,,,
relating to this string, the normal way of representing it would be 'echo "values" > file.txt' but by doing this way, it opens up a way to do something that i have been trying to do, and that is how to write multiple variables into one string but one at a time. what i mean is, there are times when i need to build a string and output it to a file, but not have it write a newline each time. basically string + string + sting...
create a file called "return" with one empty line in it.
then create test.bat
Code: Select all
@echo off
set a=aa
:: do some commands
set b=bb
:: do other commands
set c=cd
:: keep doing commands
set d=ef
:: all done with saving var's
:: so create file1.txt with vars but one on each line
> file1.txt echo %a%
>> file1.txt echo %b%
>> file1.txt echo %c%
>> file1.txt echo %d%
:: all done with saving file1.txt
type file1.txt
:: now create file2.txt with text all on one line
> file2.txt set /p test=%a%<enter
::do other commands
>> file2.txt set /p test=%b%<enter
:: something else to do
>> file2.txt set /p test=%c%<enter
:: more things
>> file2.txt set /p test=%d%<enter
:: all done with file2.txt
type file2.txt
[output]
file1.txt
aa
bb
cd
ef
file2.txt
aabbcdef
[/output]
so the question is how to write var's to a file and have the sting be just one line, but better than my solution? i dont mean just do "set string=val1 + val2 + val3.." but have the ability to write a value to a file, then do computations, return a value and write that to the file, not on a newline, but the same existing line. it seems like the way that im doing it now is a good way to do it. eg "> filename.ext commands"
appreciate the help!