title: remove extraneous characters from a filename
body: <p>I have been tasked a little above my head with taking a repository of files and removing excess garbage characters from the filename and saving the renamed file in a different directory folder.</p>
  
  <p>An example of the filenames are:</p>
  
  <pre>
  100-expresstoll.pdf
  1000-2012-09-29.jpg
  10000-2014-01-15_14.03.22.jpg
  10001-2014-01-15_19.05.24.jpg
  10002-2014-01-15_21.30.23.jpg
  10003-2014-01-16_07.33.54.jpg
  10004-2014-01-16_13.33.21.jpg
  10005-Feb 4, 2014.jpeg
  10006-O'Reilly_Media,_Inc..pdf
  </pre>
  
  <p>First group of numbers at the beginning are record IDs and are to be retained along with the file's extension. Everything else between the record IDs and the file extension needs to be dropped.</p>
  
  <p>For example, the final name for first three files would be:</p>
  
  <pre>
  100.pdf
  1000.jpg
  10000.jpg
  </pre>
  
  <p>I have read <a href="https://stackoverflow.com/questions/12590931/remove-character-from-file-name-in-powershell">Removing characters</a> and <a href="https://stackoverflow.com/questions/21118970/batch-rename-files-in-a-directory-by-rearranging-filenames">Rearranging filenames</a> in addition to other postings, but the complexity of having a variable character length at the front, a variable number of intermediary characters to be removed and variable file extension types have really tossed this beyond my limited PowerShell reach.</p>