From bdc5ab96025c40cdbb9c4a0a6c97b48826ae3501 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Sun, 2 Jul 2023 11:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E9=A2=98=E5=8F=B7=E6=B8=85=E7=82=B9=20=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/文件夹题号清点.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 工具v2/文件夹题号清点.py diff --git a/工具v2/文件夹题号清点.py b/工具v2/文件夹题号清点.py new file mode 100644 index 00000000..f0cc0c79 --- /dev/null +++ b/工具v2/文件夹题号清点.py @@ -0,0 +1,16 @@ +rootpath = "d:/temp/dirtest" # 设置需要遍历的文件目录 + +from database_tools import * + +texfiles, texpath = GetValidTexFiles(rootpath) +for path in texpath: + output_dict = {} + for texfile in [f for f in texfiles if f.startswith(path)]: + output_dict[os.path.split(texfile)[1]] = re.findall(r"\((\d{6})\)",ReadTextFile(texfile)) + output = "" + for name in sorted(output_dict): + output += name + "\n" + output += "\n".join(output_dict[name]) + output += "\n\n\n" + SaveTextFile(output,os.path.join(path,"题号清点.txt")) # 在每个有含题号的.tex文件所在的目录中生成 题号清点.txt + print("已完成文件夹 %s 中的题号清点"%path)