you should really pythonize this some more with your dir operations check out os makedirs  shutil rmtree  etc rather than rm  rf  mkdir s here and there also for some of your more complex string formats consider using  s  s blah var var var rather than  var var var 