tree batch - looping output
<p>I am trying to make a program that will give me the tree of my C: drive as a .txt file in batch. the program, when run, prints the following to the text file tree.txt:</p>

<pre><code>C:\&gt;cd C:\ 

C:\&gt;tree /a  1&gt;&gt;tree.txt 

C:\&gt;cd C:\ 

C:\&gt;tree /a  1&gt;&gt;tree.txt 

C:\&gt;cd C:\ 

C:\&gt;tree /a  1&gt;&gt;tree.txt 
</code></pre>

<p>this is very strange, as it continues to print indefinitely and prints the entirety of the code to the file instead of the tree. My code is as follows:</p>

<pre><code>cd C:\
tree /a &gt;&gt; tree.txt
</code></pre>

<p>any ideas? Thanks in advance!</p>