title: Moving files based on file name with powershell
body: <p>I need to parse a file name and move the file to a folder based on part of the file name.</p>
  
  <p>Lets say I have several files in a folder C:\SYSLOG\Servers and Firewall\Logs.  They are log files from several different servers or devices..  I need to move them to our NAS for archival.  Sample file names:</p>
  
  <pre><code> Boston.North.Application.S01.120613.log
   Boston.South.Application.S12.122513.log
   Lexington.System.S02.073013.log
   Lexington.System.S22.073013.log
   Madison.IPS.S01.050414.txt
  </code></pre>
  
  <p>I need to move them to a corresponding folder on the NAS.  My folder structure looks like this:</p>
  
  <pre><code> \\NAS\Logs\Boston North Application
   \\NAS\Logs\Boston South Application
   \\NAS\Logs\Lexington System
   \\NAS\Logs\Madison IPS
  </code></pre>
  
  <p>So basically I am wanting to parse the file name for everything to the left of the server (Sxx), and replace the . with spaces to create the destination folder name.</p>
  
  <p>The files are not always .log files.  All files have a .Sxx in the name and xx will always be numbers.  If destination folder does not exist, then skip the file.  There are no subfolders in C:\SYSLOG\Servers and Firewall\Logs.</p>
  
  <p>I think I am trying to do something similar to <a href="https://stackoverflow.com/questions/21117208/powershell-to-move-files-based-on-part-of-file-name">powershell to move files based on part of file name</a> </p>