main.py 412 B

12345678910111213
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os, sys, re
  4. files = [f for f in os.listdir('.') if os.path.isfile(f) and f.startswith(sys.argv[1])]
  5. for f in files:
  6. print f
  7. match = re.match(r'([a-zA-Z.]*).(S[0-9]*E[0-9]*).([a-zA-Z0-9äöüÄÖÜß\-\.\,\w]*)', f)
  8. newName = match.group(1) + "-" + match.group(2) + "-" + match.group(3)
  9. print newName
  10. os.rename(f, newName)
  11. print "\n"