Explorar o código

Series in format Series.Name.SXEY.Description.file can be renamed.

Moritz Schmidt %!s(int64=10) %!d(string=hai) anos
achega
1c438c634a
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      main.py

+ 13 - 0
main.py

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