title: How does Windows determine/handle the DOS short name of any given file?
body: <p>I have a folder with these files:</p>
  
  <pre><code>alongfilename1.txt &lt;--- created first
  alongfilename3.txt &lt;--- created second
  </code></pre>
  
  <p>When I run <strong>DIR /x</strong> in command prompt, I see these short names assigned:</p>
  
  <pre><code>ALONGF~1.TXT alongfilename1.txt
  ALONGF~2.TXT alongfilename3.txt
  </code></pre>
  
  <p>Now, if I add another file:</p>
  
  <pre><code>alongfilename1.txt 
  alongfilename2.txt &lt;--- created third
  alongfilename3.txt
  </code></pre>
  
  <p>I see this:</p>
  
  <pre><code>ALONGF~1.TXT alongfilename1.txt
  ALONGF~3.TXT alongfilename2.txt
  ALONGF~2.TXT alongfilename3.txt
  </code></pre>
  
  <p>Fine. It seems to be assigning the "~#" according to the date/time that I created the file. Is this correct?</p>
  
  <p>Now, if I delete "alongfilename1.txt", the other two files <strong>keep their short names</strong>.</p>
  
  <pre><code>ALONGF~3.TXT alongfilename2.txt
  ALONGF~2.TXT alongfilename3.txt
  </code></pre>
  
  <p>When will that ID (in this case, ~1) be released for use in another shortname. Will it ever? </p>
  
  <p>Also, is it possible that a file on my machine has a short name of X, whereas the same file has a short name of Y on another machine? I'm particularly concerned for installations whose custom actions utilize DOS short names.</p>
  
  <p>Thanks, guys.</p>