forked from ss14Starlight/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStarlightify.py
More file actions
35 lines (32 loc) · 1.03 KB
/
Starlightify.py
File metadata and controls
35 lines (32 loc) · 1.03 KB
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
#!/usr/bin/env python3
import os
import shutil
root = "."
old_name = "_Impstation"
new_name = "_Starlight"
def merge_dirs(src, dst):
"""Recursively merge src into dst, then remove src."""
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
if not os.path.exists(d):
shutil.move(s, d)
else:
merge_dirs(s, d)
else:
if os.path.exists(d):
print(f"Overwriting file: {d}")
os.remove(d)
shutil.move(s, d)
os.rmdir(src)
for dirpath, dirnames, filenames in os.walk(root, topdown=False):
for d in dirnames:
if d == old_name:
old_path = os.path.join(dirpath, d)
new_path = os.path.join(dirpath, new_name)
print(f"Processing: {old_path} -> {new_path}")
if os.path.exists(new_path):
merge_dirs(old_path, new_path)
else:
shutil.move(old_path, new_path)