title: Batch Script to Delete Files with Unique Root Stem in Directory
body: <p>Is it possible to write a batch file that deletes all files in a directory for which the first n characters of the file's root name do not match the first n characters of any other filenames in that directory? For instance, suppose the directory contains the following:</p>
  
  <pre><code>Purcell_HenryA.txt
  Purcell_HenryB.txt
  Casaubon_IsaacA.txt
  </code></pre>
  
  <p>In this case, we would want to delete all files in the directory whose first 13 characters did not match the first 13 characters in any other files in the directory. (That is, we'd want to delete only Casaubon_IsaacA.txt.) I have tracked down scripts that delete all files with unique extensions in a directory, but don't know how to begin to write this script, and would therefore be grateful for any leads on the question.</p>