From cd996e96d0bf5ec384615609509a0c7d14028ece Mon Sep 17 00:00:00 2001 From: roger_home_pc Date: Wed, 16 Aug 2023 22:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E9=80=BB=E8=BE=91,=E6=B7=BB=E5=8A=A0=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- file.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/file.py b/file.py index 9f74749..c7d56ca 100644 --- a/file.py +++ b/file.py @@ -126,19 +126,19 @@ class FilesCollection: # print('todo[0] - leaf[0]') # print(todo[0]) # print(leaf[0]) - if len(leaf[1]) == 0: + if len(leaf[1]) == 0: # 文件夹为0个, 文件有0个或多个 # print(1) for file in leaf[2]: move_files.append([os.path.join(leaf[0], file), os.path.join(todo[1], file)]) - elif len(leaf[1]) == 1 and len(leaf[2]) == 0: + elif len(leaf[1]) == 1 and len(leaf[2]) == 0: # 1个文件夹 和 0个文件 # print(2) temp.append([os.path.join(leaf[0], leaf[1][0]), todo[1]]) - elif len(leaf[1]) == 1 and len(leaf[2]) > 0: + elif len(leaf[1]) == 1 and len(leaf[2]) > 0: # 1个文件夹 和 多个文件 # print(3) - temp.append([os.path.join(leaf[0], leaf[1][0]), os.path.join(leaf[0], leaf[1][0])]) + temp.append([os.path.join(leaf[0], leaf[1][0]), os.path.join(todo[1], leaf[1][0])]) for file in leaf[2]: move_files.append([os.path.join(leaf[0], file), os.path.join(todo[1], file)]) - elif len(leaf[1]) > 1: + elif len(leaf[1]) > 1: # 有多个文件夹 # print(4) for folder in leaf[1]: temp.append([os.path.join(leaf[0], folder), os.path.join(todo[1], folder)]) @@ -154,6 +154,7 @@ class FilesCollection: # 移动文件 def move_files(self): for move in self.get_move_files(): + # print(move) if not os.path.exists(os.path.dirname(move[1])): os.makedirs(os.path.dirname(move[1])) shutil.move(move[0], move[1])