title: Splitting content from a single folder to multiple sub folders using Python
body: <p>In my file, I have a large number of images in <strong>jpg</strong> format and they are named <strong>[fruit type].[index].jpg</strong>.<br>
  Instead of manually making three new sub folders to copy and paste the images into each sub folder, is there some python code that can parse through the name of the images and choose where to redirect the image to based on the <code>fruit type</code> in the name, at the same time create a new sub folder when a new <code>fruit type</code> is parsed?</p>
  
  <hr>
  
  <p><strong>Before</strong></p>
  
  <ul>
  <li>TrainingSet (file)
  
  <ul>
  <li>apple.100.jpg</li>
  <li>apple.101.jpg</li>
  <li>apple.102.jpg</li>
  <li>apple.103.jpg</li>
  <li>peach.100.jpg</li>
  <li>peach.101.jpg</li>
  <li>peach.102.jpg</li>
  <li>orange.100.jpg</li>
  <li>orange.101.jpg</li>
  </ul></li>
  </ul>
  
  <hr>
  
  <p><strong>After</strong></p>
  
  <ul>
  <li>TrainingSet (file)
  
  <ul>
  <li>apple(file)
  
  <ul>
  <li>apple.100.jpg</li>
  <li>apple.101.jpg</li>
  <li>apple.102.jpg</li>
  <li>apple.103.jpg</li>
  </ul></li>
  <li>peach(file)
  
  <ul>
  <li>peach.100.jpg</li>
  <li>peach.101.jpg</li>
  <li>peach.102.jpg</li>
  </ul></li>
  <li>orange(file)
  
  <ul>
  <li>orange.100.jpg</li>
  <li>orange.101.jpg</li>
  </ul></li>
  </ul></li>
  </ul>