title: Automatically move files with python
body: <p>I am trying to make a python script that will allow me to place music into one large folder so when I run the script it will create folders according to the first part of the music files. So let's say I have a music file called <code>OMFG - Ice Cream.mp3</code> I would like to be able to split each music file name so that instead of <code>OMFG - Ice Cream.mp3</code> it would chop it off in this case <code>Ice Cream.mp3</code> and then it would use <code>OMFG</code> to create a folder called that. After it created that folder I would then like to find out a way to then move, in this case <code>OMFG - Ice Cream.mp3</code> into the folder that was just created.</p>
  
  <p>Here is my code so far:</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  
  # path = "/Users/alowe/Desktop/testdir2"
  # os.listdir(path)
  songlist = ['OMFG - Ice Cream.mp3', 'OMFG - Hello.mp3', 'Dillistone - Sad &amp; High.mp3']
  teststr = str(songlist)
  songs = teststr.partition('-')[0]
  print ''.join(songs)[2:-1]
  </code></pre>
  
  <p>My main trouble is how to loop through each object in the string.</p>
  
  <p>Thanks, 
  Alex</p>