Making a file using Batch Files

  • Thread starter Thread starter Algren
  • Start date Start date
  • Tags Tags
    Batch File files
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
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?
 
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.