Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathpath.py
More file actions
Latest commit
36 lines (32 loc) · 1.42 KB
/
Copy pathpath.py
File metadata and controls
36 lines (32 loc) · 1.42 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
36
importos
code_path="Codes"
users=os.listdir(code_path)
base_path=os.path.abspath(
os.path.dirname(os.path.abspath(__file__)) +os.path.sep+"."
)
foruserinusers:
# skip .DS_Store / .gitignore etc
ifuser.startswith("."):
continue
# for directories
forparent, directories, _inos.walk(os.path.join(code_path, user)):
fordirectoryindirectories:
if" "indirectory:
origin_path=os.path.join(parent, directory)
current_path=os.path.join(parent, directory.replace(" ", "-"))
origin_abs_path=os.path.join(base_path, origin_path)
current_abs_path=os.path.join(base_path, current_path)
print(origin_abs_path)
print(current_abs_path)
os.system("\\mv '%s' '%s'"% (origin_abs_path, current_abs_path))
# for files
forparent, _, filesinos.walk(os.path.join(code_path, user)):
forfileinfiles:
if" "infile:
origin_path=os.path.join(parent, file)
current_path=os.path.join(parent, file.replace(" ", "-"))
origin_abs_path=os.path.join(base_path, origin_path)
current_abs_path=os.path.join(base_path, current_path)
print(origin_abs_path)
print(current_abs_path)
os.system("\\mv '%s' '%s'"% (origin_abs_path, current_abs_path))