""" Step 1: Scan a restored FCCS backup directory for drawer IDs. Every subdirectory in the backup root corresponds to a drawer. Writes the sorted list of drawer IDs to the configured drawer_id_file. """ import os import sys from fccs_config import parse_args, load_config, make_logger def main(): args = parse_args() cfg = load_config(args.config) log = make_logger(cfg.get("paths", "log_file")) backup_dir = cfg.get("paths", "backup_dir") output_file = cfg.get("paths", "drawer_id_file") if not os.path.isdir(backup_dir): log(f"ERROR: backup directory not found: {backup_dir}") sys.exit(1) drawer_ids = sorted( name for name in os.listdir(backup_dir) if os.path.isdir(os.path.join(backup_dir, name)) ) with open(output_file, "w", encoding="utf-8") as f: for did in drawer_ids: f.write(did + "\n") log(f"Found {len(drawer_ids)} drawers, written to {output_file}") if __name__ == "__main__": main()