|
| 1 | +import os |
| 2 | + |
| 3 | +code_path = "Codes" |
| 4 | +users = os.listdir(code_path) |
| 5 | +base_path = os.path.abspath( |
| 6 | + os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "." |
| 7 | +) |
| 8 | + |
| 9 | +for user in users: |
| 10 | + # skip .DS_Store / .gitignore etc |
| 11 | + if user.startswith("."): |
| 12 | + continue |
| 13 | + |
| 14 | + # for directories |
| 15 | + for parent, directories, _ in os.walk(os.path.join(code_path, user)): |
| 16 | + for directory in directories: |
| 17 | + if " " in directory: |
| 18 | + origin_path = os.path.join(parent, directory) |
| 19 | + current_path = os.path.join(parent, directory.replace(" ", "-")) |
| 20 | + origin_abs_path = os.path.join(base_path, origin_path) |
| 21 | + current_abs_path = os.path.join(base_path, current_path) |
| 22 | + print(origin_abs_path) |
| 23 | + print(current_abs_path) |
| 24 | + os.system("\\mv '%s' '%s'" % (origin_abs_path, current_abs_path)) |
| 25 | + |
| 26 | + # for files |
| 27 | + for parent, _, files in os.walk(os.path.join(code_path, user)): |
| 28 | + for file in files: |
| 29 | + if " " in file: |
| 30 | + origin_path = os.path.join(parent, file) |
| 31 | + current_path = os.path.join(parent, file.replace(" ", "-")) |
| 32 | + origin_abs_path = os.path.join(base_path, origin_path) |
| 33 | + current_abs_path = os.path.join(base_path, current_path) |
| 34 | + print(origin_abs_path) |
| 35 | + print(current_abs_path) |
| 36 | + os.system("\\mv '%s' '%s'" % (origin_abs_path, current_abs_path)) |
0 commit comments