-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathsanitize-folders.py
22 lines (20 loc) · 1021 Bytes
/
sanitize-folders.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import shutil
if __name__ == '__main__':
# foreach json file open it and check if files exist
for dirpath, dirnames, filenames in os.walk("mp3", topdown=False):
try:
for dirname in dirnames:
# Check if the directory name matches the target_name
if dirname == "entree":
full_dir_path = os.path.join(dirpath, dirname)
new_full_dir_path = os.path.join(dirpath, "in")
shutil.move(full_dir_path, new_full_dir_path)
print(f"Renamed '{full_dir_path}' to '{new_full_dir_path}'")
if dirname == "sortie":
full_dir_path = os.path.join(dirpath, dirname)
new_full_dir_path = os.path.join(dirpath, "out")
shutil.move(full_dir_path, new_full_dir_path)
print(f"Renamed '{full_dir_path}' to '{new_full_dir_path}'")
except Exception as e:
print(f"Random Exeption:\n{e}")