title: Python 3.5: Moving files to folder based on filenames
body: <p>I have a folder with 10 images that I wish to move into a new folder based on it's current filenames. I've successfully been able to move every images in the folder into a new folder but I've yet to figure out how to move the files based on it's filename, For example below I want to move the images accordingly.</p>
  
  <ul>
  <li>1600_01.jpg ---> folder 1</li>
  <li>1700_01.jpg ---> folder 1</li>
  <li>1800_02.jpg ---> folder 2</li>
  <li>1900_02.jpg ---> folder 2</li>
  <li>2000_03.jpg ---> folder 3</li>
  <li>2100_03.jpg ---> folder 3</li>
  </ul>
  
  <p>This is my code thus far for moving entire files in a folder to a destination that I want.</p>
  
  <pre><code># Moving Files from one place to another
  import shutil
  import os 
  
  sourcefile = 'Desktop/00/'
  destination = 'Desktop/00/d'
  
  # Loading the files from source
  files = os.listdir(path=sourcefile)
  
  # Reading the files in folder
  for f in files:
      shutil.move(sourcefile+f, destination)
  </code></pre>