From 1704ecf3799855a9cf4c2d4c5dd2950a8047bb2c Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Sun, 15 Sep 2024 12:11:43 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/更新文件名.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py/更新文件名.py b/py/更新文件名.py index edc92e4..73d4fa2 100644 --- a/py/更新文件名.py +++ b/py/更新文件名.py @@ -37,7 +37,9 @@ def rename_files(): # 删除以上次时间加上初始文件名命名的文件 if last_update_time: for old_filename in all_files: - if any(old_filename.startswith(f"{last_update_time}") and old_filename.endswith(tuple(initial_filenames))): + starts_with_last_time = old_filename.startswith(f"{last_update_time}") + ends_with_initial_filename = any(old_filename.endswith(init_filename) for init_filename in initial_filenames) + if starts_with_last_time and ends_with_initial_filename: full_old_path = os.path.join(os.getcwd(), old_filename) if os.path.exists(full_old_path): os.remove(full_old_path)