-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
reorganize_files.py
35 lines (25 loc) · 904 Bytes
/
reorganize_files.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
import os
import re
import shutil
def main():
if not os.path.exists("sounds"):
os.mkdir("sounds")
for dirname in os.listdir("PLAYER_JIKKYO"):
result = re.match(r"GRP_.*_([a-z][a-z])", dirname)
if result:
language = result.group(1)
else:
language = "en"
for wavname in os.listdir(os.path.join("PLAYER_JIKKYO", dirname)):
if language != "en":
dest_name = wavname[3:]
else:
dest_name = wavname
path = os.path.join("PLAYER_JIKKYO", dirname, wavname)
dest = os.path.join("sounds", language, dest_name)
if not os.path.exists(os.path.join("sounds", language)):
os.mkdir(os.path.join("sounds", language))
shutil.copyfile(path, dest)
print(f"{path} -> {dest}")
if __name__ == "__main__":
main()