From 28957ebe48f5064e8251e5447812ad820c3abcd6 Mon Sep 17 00:00:00 2001 From: IVEN-CN <13377529851@stu.gdou.edu.cn> Date: Mon, 22 Jan 2024 11:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=A6=81=E9=A2=9C=E8=89=B2=E5=88=86=E7=B1=BB=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- office_automation.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/office_automation.py b/office_automation.py index d6e4f88..e56d31e 100644 --- a/office_automation.py +++ b/office_automation.py @@ -5,6 +5,7 @@ import os import color_div.color_divider import re +import os def done(func): def wrapper(*args, **kwargs): @@ -13,7 +14,7 @@ def wrapper(*args, **kwargs): return wrapper @done -def main(*num, path): # num是不需要移动到主图文件夹的图片序号,类似于(1),(2),(3) +def main(*num, path, ifcolordiv=True): # num是不需要移动到主图文件夹的图片序号,类似于(1),(2),(3) list_path = renamer.main1.get_file_path(path) img1200_path = [] img_path = [] @@ -58,9 +59,33 @@ def main(*num, path): # num是不需要移动到主图文件夹的图片 # 重命名主图文件夹的文件 renamer.main2.rename2(os.path.join(path, '主图')) - # 颜色分类 - color_div.color_divider.main(path=path, erea='area0.npy') - color_div.color_divider.main(path=path, erea='area1.npy') + if ifcolordiv: + # 颜色分类 + color_div.color_divider.main(path=path, erea='area0.npy') + color_div.color_divider.main(path=path, erea='area1.npy') + else: + list_path = renamer.main1.get_file_path(path) # 更新list_path + for i in list_path: + if '主图' in i or 'main' in i: + os.remove(i) + + folder_names = ['800X1200', '800X800', '750X1000'] + for folder_name in folder_names: + folder_path = os.path.join(path, folder_name) + os.makedirs(folder_path, exist_ok=True) + for i in list_path: + if '800' in i: + shutil.move(i, os.path.join(path, '800X1200')) + elif '1000' in i: + shutil.move(i, os.path.join(path, '750X1000')) + elif '1200' in i: + shutil.move(i, os.path.join(path, '800X800')) + else: + pass + + if __name__ == '__main__': + main(path=r'D:\41short\KC-41-XOU179') + if __name__ == '__main__': main(path=r'D:\41short\KC-41-XOU179') \ No newline at end of file