| import os |
| import shutil |
|
|
| |
| source_dir = os.path.dirname(os.path.abspath(__file__)) |
| archive_dir = os.path.join(source_dir, "TMP") |
|
|
| |
| hex_digits = "0123456789ABCDEF" |
|
|
| |
| for digit in hex_digits: |
| folder_path = os.path.join(archive_dir, digit) |
| os.makedirs(folder_path, exist_ok=True) |
|
|
| |
| for filename in os.listdir(archive_dir): |
| |
| if filename.endswith(".zip"): |
| |
| first_digit = filename[0].upper() |
| if first_digit in hex_digits: |
| source_file = os.path.join(archive_dir, filename) |
| dest_file = os.path.join(archive_dir, first_digit, filename) |
| print(f"Moving {filename} to folder {first_digit}/") |
| shutil.move(source_file, dest_file) |
| else: |
| print(f"Skipping file {filename}: first character '{filename[0]}' is not a valid hex digit.") |
|
|