From 7e12a3270bf853fdf194fccd3bbef52d409ddb87 Mon Sep 17 00:00:00 2001 From: tzquant_zq Date: Mon, 6 May 2024 19:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'tz=5Fcrypto=5Fbt.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 回滚 --- tz_crypto_bt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tz_crypto_bt.py b/tz_crypto_bt.py index 3f299a0..524c2b3 100644 --- a/tz_crypto_bt.py +++ b/tz_crypto_bt.py @@ -49,7 +49,12 @@ for directory in directories_to_move: # 检查源目录是否存在 if os.path.isdir(source_path): # 使用shutil.move来移动目录 - shutil.move(source_path, target_path) + if os.path.exists(target_path): + if os.path.isdir(target_path): + shutil.rmtree(target_path) # 删除整个目录及其内容 + else: + os.remove(target_path) # 删除文件 + shutil.move(source_path, target_path) print(f"Moved {directory} to {target_path}") else: print(f"Directory {directory} does not exist in the current directory.")