from pathlib import Path import shutil source = Path(__file__).resolve().parent for project in (Path(r'C:\wechat_rpa'), Path(r'C:\kefu\wechat_rpa')): backup = project / 'backups' / 'single-instance-tray-20260917' backup.mkdir(parents=True, exist_ok=True) for name in ('desktop_instance.py', 'test_desktop_instance.py'): target = project / name if target.exists() and not (backup / name).exists(): shutil.copy2(target, backup / name) shutil.copy2(source / name, target) print(target)