Dir sort discrepency
<p>I have a batch file that copies the contents of a folder (sourcefolder) to another (destfolder) using the following code:</p>

<pre><code>robocopy /mt:128 /e /r:1 /w:1 /tee /log:%robolog% %sourcefolder% %destfolder%
</code></pre>

<p>I then want to generate a list of all of the files in both of these locations sorted by name. I am using the following lines to generate these lists:</p>

<pre><code>dir /s /b /a-d /o:n %sourcefolder% &gt; %sourcelist%
dir /s /b /a-d /o:n %destfolder% &gt; %destlist%
</code></pre>

<p>For some reason, the lists aren't being sorted the same way. For example, the source list might look something like:  </p>

<pre><code>sourcefolder\subfolder1\text.txt  
sourcefolder\subfolder2\abc.txt  
sourcefolder\subfolder3\file.exe
</code></pre>

<p>But the destination list might look like:</p>

<pre><code>destfolder\subfolder2\abc.txt  
destfolder\subfolder3\file.exe  
destfolder\subfolder1\text.txt  
</code></pre>

<p>I can't figure out why the dir command is generating lists that aren't in the same order. I need to make sure that these list are in identical order before I move to the next part of my batch file.</p>