title: File moving according to substring derived from file name
body: <p>Ihave started a simple script in order to move files of a certain prefix to a folder of the same name eg: W100_11.jpg W100_12.jpg in to folder W100.</p>
  
  <p>Thanks to help from the answers below I have progressed and have a successful loop which can iterate through the file sin the folder, I am having issues with the -filter switch and when trying to use the move-item cmdlet I am getting errors</p>
  
  <p>The current code is:</p>
  
  <pre><code>$sourceDir = read-host "Please enter source Dir:"
  $format = read-host "Format to look for with .  :"
  #$length = read-host "length of folder name:"
  
  gci -Path $sourceDir | % {
      If( -not $_.PSIsContainer)
      {
          $path = $sourceDir + "\" + $_.Name.substring(0, 3)
          $_
          if(-not (Test-Path $path))
          {
              mkdir $path
  
          }
          move $_.fullname $path
  
      }  
  }
  </code></pre>
  
  <p>I am still having issues when using the -filter switch. This is a partial solution to the issue</p>