import os import time def check_and_rename_file(original_path, new_path, timeout_sec=30, poll_interval=0.5): """ Waits for a file to exist at original_path, then renames it to new_path. Returns True if successful, False if timeout. """ elapsed = 0 while not os.path.exists(original_path): time.sleep(poll_interval) elapsed += poll_interval if elapsed >= timeout_sec: return False try: os.rename(original_path, new_path) return True except Exception as e: print(f"Error renaming file: {e}") return False
Collaborate with other users in our discussion forums
A valid service agreement or active software subscription may be required, and support options vary by country.
Helpful
Not Helpful