 
import os

from shutil import copyfile



files = os.listdir('.')
print files


for f in files:
        if 'dat' in f:
            stats = f.split('_')
            print stats[2]
            
        try:
            os.mkdir(stats[2])
        except:
            pass
        
        
        copyfile(f, str(stats[2])+'/'+f)
