| import os |
| import shutil |
|
|
| |
| source_dir = os.path.dirname(os.path.abspath(__file__)) |
| odcs_decrypted_dir = os.path.join(source_dir, "TMP") |
|
|
| |
| hex_digits = "0123456789ABCDEF" |
|
|
| |
| prefixes = ["live", "live2"] |
|
|
| for prefix in prefixes: |
| prefix_dir = os.path.join(odcs_decrypted_dir, prefix) |
| os.makedirs(prefix_dir, exist_ok=True) |
| |
| for digit in hex_digits: |
| subfolder = os.path.join(prefix_dir, digit) |
| os.makedirs(subfolder, exist_ok=True) |
|
|
| |
| for filename in os.listdir(odcs_decrypted_dir): |
| if filename.endswith(".odc"): |
| |
| if "$" in filename: |
| |
| if filename.startswith("live2$"): |
| prefix = "live2" |
| elif filename.startswith("live$"): |
| prefix = "live" |
| else: |
| print(f"Skipping file {filename}: does not start with a valid prefix.") |
| continue |
|
|
| |
| parts = filename.split("$", 1) |
| if len(parts) != 2: |
| print(f"Skipping file {filename}: unexpected filename format.") |
| continue |
| uuid_part = parts[1] |
| |
| first_digit = uuid_part[0].upper() |
| if first_digit in hex_digits: |
| source_file = os.path.join(odcs_decrypted_dir, filename) |
| dest_file = os.path.join(odcs_decrypted_dir, prefix, first_digit, filename) |
| print(f"Moving {filename} to {prefix}/{first_digit}/") |
| shutil.move(source_file, dest_file) |
| else: |
| print(f"Skipping file {filename}: first character '{uuid_part[0]}' is not a valid hex digit.") |
| else: |
| print(f"Skipping file {filename}: missing '$' in filename.") |
|
|