import os import shutil def check_masked_folder(base_path): for folder_name in os.listdir(base_path): folder_path = os.path.join(base_path, folder_name) if os.path.isdir(folder_path): masked_folder_path = os.path.join(folder_path, 'masked') if os.path.isdir(masked_folder_path): if '0015.png' not in os.listdir(masked_folder_path): print(f"'0015.png' not found in: {masked_folder_path}") shutil.rmtree(folder_path) else: print(f"'masked' folder not found in: {folder_path}") base_path = '/data_160TB/2021/yangkun/gha-gaussian/datasets/maxed_data/train' check_masked_folder(base_path)