import os from pathlib import Path def list_files(startpath): path = Path(startpath) for item in path.rglob('*'): if item.is_file(): target_timestamp = 1656086400 + random.randint(1, 86400) file_path = item # 設定檔案的訪問時間和修改時間為目標時間戳 os.utime(file_path, (target_timestamp, target_timestamp)) print(f"已將檔案 {file_path} 的修改時間設定為 {target_timestamp}") startpath = 'D:\\video\西瓜' list_files(startpath)