from typing import List
import os

from utils.const import ADNI_LIST, DATA_ROOT

target_SC = DATA_ROOT / "ADNI" / "deleted_subjects" / "SC_registration"
target_M06 = DATA_ROOT / "ADNI" / "deleted_subjects" / "M06_registration"
target_M12 = DATA_ROOT / "ADNI" / "deleted_subjects" / "M12_registration"
target_M24 = DATA_ROOT / "ADNI" / "deleted_subjects" / "M24_registration"
TARGET_FOLDERS = [target_M24, target_M12, target_M06, target_SC]

moving_files = [
    "006_S_0547",
    "011_S_0003",
    "011_S_0053",
    "033_S_0889",
    "051_S_1296",
    "062_S_0690",
    "098_S_0149",
    "126_S_1221",
    "127_S_1382",
    "128_S_0167",
    "128_S_0266",
]


def get_the_failed_files() -> List:
    failed_file_list = []
    for adni in ADNI_LIST:
        failed_file_list_time_point = []
        for moving_file in moving_files:
            files = list(adni.glob(f"**/*{moving_file}*"))
            failed_file_list_time_point.extend(files)
        failed_file_list.append(failed_file_list_time_point)
    return failed_file_list


if __name__ == "__main__":
    failed_file_list = get_the_failed_files()
    for failed_file_time_point, fold in zip(failed_file_list, TARGET_FOLDERS):
        for failed_file in failed_file_time_point:
            os.system(f"mv {failed_file} {fold}")
            print(f"exec: mv {failed_file} {fold}")

from typing import List
import os

from utils.const import ADNI_LIST, DATA_ROOT

target_SC = DATA_ROOT / "ADNI" / "deleted_subjects" / "SC_registration"
target_M06 = DATA_ROOT / "ADNI" / "deleted_subjects" / "M06_registration"
target_M12 = DATA_ROOT / "ADNI" / "deleted_subjects" / "M12_registration"
target_M24 = DATA_ROOT / "ADNI" / "deleted_subjects" / "M24_registration"
TARGET_FOLDERS = [target_M24, target_M12, target_M06, target_SC]

moving_files = [
    "006_S_0547",
    "011_S_0003",
    "011_S_0053",
    "033_S_0889",
    "051_S_1296",
    "062_S_0690",
    "098_S_0149",
    "126_S_1221",
    "127_S_1382",
    "128_S_0167",
    "128_S_0266",
]


def get_the_failed_files() -> List:
    failed_file_list = []
    for adni in ADNI_LIST:
        failed_file_list_time_point = []
        for moving_file in moving_files:
            files = list(adni.glob(f"**/*{moving_file}*"))
            failed_file_list_time_point.extend(files)
        failed_file_list.append(failed_file_list_time_point)
    return failed_file_list


if __name__ == "__main__":
    failed_file_list = get_the_failed_files()
    for failed_file_time_point, fold in zip(failed_file_list, TARGET_FOLDERS):
        for failed_file in failed_file_time_point:
            os.system(f"mv {failed_file} {fold}")
            print(f"exec: mv {failed_file} {fold}")
