title: Using Powershell to move documents to a folder based on file name
body: <p>I have searched your database for answers and find things that are similar, but not quite what I am needing. I do not know how to code well enough to take some of the examples and modify them to fit my needs.</p>
  
  <p>I have documents that I need to move to a folder that has the same name as the beginning of the document name. Here are a couple of example of my document names (ParcelNum_CountyNum_Year_DocType.pdf)</p>
  
  <ul>
  <li>188777_014_2013_NOAV.pdf</li>
  <li>242353_227_2014_HRGNOTICE.pdf   </li>
  <li>R506275_246_2013_NOAV.pdf</li>
  </ul>
  
  <p>I currently have the documents residing in a single folder named by the county number (the 3 digit number between the first _ and the 2nd _)</p>
  
  <p>I have folders created that are named by the ParcelNum, which is the first set of characters/numbers at the beginning and before the first _. I need Powershell to read the first portion of the document name stopping at the first _ and place it in the folder that matches that numchar.
  So for example the first document example above is named 188777_014_2013_NOAV.pdf and resides at the root of the CountyNum folder named 014.
  For that example, I would need it to be moved from the root folder 014, into its subfolder named 188777.</p>
  
  <p>I hope that makes sense. Please feel free to ask questions.</p>
  
  <p>Thank you,</p>