Making a file using Batch Files

  • Thread starter Thread starter Algren
  • Start date Start date
  • Tags Tags
    Batch File files
AI Thread Summary
To create a .txt file using a batch file with specific multi-line content, including special characters like '>', users can utilize the echo command with special formatting. Enclosing the text in %%"%% blocks can help bypass issues with special characters, allowing the command to execute correctly. For example, using the syntax echo %%"%% something ii >>newfile %%"%% >reg.bat can effectively write to the file. If this method does not yield the desired results, trying single percents, such as echo %"% something ii >>newfile %"% >reg.bat, may also work. Users should be aware that other special characters might also pose challenges when echoing content to a file.
Algren
Messages
74
Reaction score
1
How do i create a .txt file using a batch file with something written on it.

For example, i want to write this:-

i>>n;
i<<n;
a
b
c...

It has multiple lines and '>', so echo (text) >> test.txt doesn't work.

Is there a better way?
 
Technology news on Phys.org
Depending on the complexity of your task, it may be sufficient to use this technique:

Code:
It's usually enough to enclose it between two %%"%% blocks, like this:

echo %%"%% something ii >>newfile %%"%% >reg.bat

It may not look pretty but it usually works just fine.

If %%"%% doesn't seem to do what you want, try single percents like this:

Code:
echo %"% something ii >>newfile %"% >reg.bat

I no longer have a MSDOS system to try stuff out. You are likely to discover there are other characters that cause you problems when you try to echo them to a second file, too.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top