|
|
|
@ -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]) |
|
|
|
|