-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.py
37 lines (27 loc) · 781 Bytes
/
tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import re
import os
def tryint(s):
try:
return int(s)
except:
return s
def alphanum_key(s):
return [tryint(c) for c in re.split('([0-9]+)', s)]
def sort_nicely(l):
l.sort(key=alphanum_key)
def move():
cpt = 0
folder_in = "DARLING in the FRANXX - 1 cleared"
folder_out = "a"
for folder, subfolder, files in os.walk(folder_in):
if len(files) == 0:
continue
sort_nicely(files)
for f in files:
path_in = os.path.join(folder, f)
file, ext = os.path.splitext(path_in)
name = "{:0>4}".format(cpt)
path_out = os.path.join(folder_out, name + ext)
cpt += 1
# print(path_in, path_out)
os.rename(path_in, path_out)